Video decoding implementations for a graphics processing unit

ABSTRACT

Video decoding innovations for multithreading implementations and graphics processor unit (“GPU”) implementations are described. For example, for multithreaded decoding, a decoder uses innovations in the areas of layered data structures, picture extent discovery, a picture command queue, and/or task scheduling for multithreading. Or, for a GPU implementation, a decoder uses innovations in the areas of inverse transforms, inverse quantization, fractional interpolation, intra prediction using waves, loop filtering using waves, memory usage and/or performance-adaptive loop filtering. Innovations are also described in the areas of error handling and recovery, determination of neighbor availability for operations such as context modeling and intra prediction, CABAC decoding, computation of collocated information for direct mode macroblocks in B slices, reduction of memory consumption, implementation of trick play modes, and picture dropping for quality adjustment.

BACKGROUND

Companies and consumers increasingly depend on computers to process,distribute, and play back high quality video content. Engineers usecompression (also called source coding or source encoding) to reduce thebit rate of digital video. Compression decreases the cost of storing andtransmitting video information by converting the information into alower bit rate form. Decompression (also called decoding) reconstructs aversion of the original information from the compressed form. A “codec”is an encoder/decoder system.

Compression can be lossless, in which the quality of the video does notsuffer, but decreases in bit rate are limited by the inherent amount ofvariability (sometimes called source entropy) of the input video data.Or, compression can be lossy, in which the quality of the video suffers,and the lost quality cannot be completely recovered, but achievabledecreases in bit rate are more dramatic. Lossy compression is often usedin conjunction with lossless compression—lossy compression establishesan approximation of information, and the lossless compression is appliedto represent the approximation.

A basic goal of lossy compression is to provide good rate-distortionperformance. So, for a particular bit rate, an encoder attempts toprovide the highest quality of video. Or, for a particular level ofquality/fidelity to the original video, an encoder attempts to providethe lowest bit rate encoded video. In practice, considerations such asencoding time, encoding complexity, encoding resources, decoding time,decoding complexity, decoding resources, overall delay, and/orsmoothness in quality/bit rate changes also affect decisions made incodec design as well as decisions made during actual encoding.

In general, video compression techniques include “intra-picture”compression and “inter-picture” compression. Intra-picture compressiontechniques compress a picture with reference to information within thepicture, and inter-picture compression techniques compress a picturewith reference to a preceding and/or following picture (often called areference or anchor picture) or pictures.

For intra-picture compression, for example, an encoder splits a pictureinto 8×8 blocks of samples, where a sample is a number that representsthe intensity of brightness or the intensity of a color component for asmall, elementary region of the picture, and the samples of the pictureare organized as arrays or planes. The encoder applies a frequencytransform to individual blocks. The frequency transform converts an 8×8block of samples into an 8×8 block of transform coefficients. Theencoder quantizes the transform coefficients, which may result in lossycompression. For lossless compression, the encoder entropy codes thequantized transform coefficients.

Inter-picture compression techniques often use motion estimation andmotion compensation to reduce bit rate by exploiting temporal redundancyin a video sequence. Motion estimation is a process for estimatingmotion between pictures. For example, for an 8×8 block of samples orother unit of the current picture, the encoder attempts to find a matchof the same size in a search area in another picture, the referencepicture. Within the search area, the encoder compares the current unitto various candidates in order to find a candidate that is a good match.When the encoder finds an exact or “close enough” match, the encoderparameterizes the change in position between the current and candidateunits as motion data (such as a motion vector (“MV”)). In general,motion compensation is a process of reconstructing pictures fromreference picture(s) using motion data.

The example encoder also computes the sample-by-sample differencebetween the original current unit and its motion-compensated predictionto determine a residual (also called a prediction residual or errorsignal). The encoder then applies a frequency transform to the residual,resulting in transform coefficients. The encoder quantizes the transformcoefficients and entropy codes the quantized transform coefficients.

If an intra-compressed picture or motion-predicted picture is used as areference picture for subsequent motion compensation, the encoderreconstructs the picture. A decoder also reconstructs pictures duringdecoding, and it uses some of the reconstructed pictures as referencepictures in motion compensation. For example, for an 8×8 block ofsamples of an intra-compressed picture, an example decoder reconstructsa block of quantized transform coefficients. The example decoder andencoder perform inverse quantization and an inverse frequency transformto produce a reconstructed version of the original 8×8 block of samples.

As another example, the example decoder or encoder reconstructs an 8×8block from a prediction residual for the block. The decoder decodesentropy-coded information representing the prediction residual. Thedecoder/encoder inverse quantizes and inverse frequency transforms thedata, resulting in a reconstructed residual. In a separate motioncompensation path, the decoder/encoder computes an 8×8 predicted blockusing motion vector information for displacement from a referencepicture. The decoder/encoder then combines the predicted block with thereconstructed residual to form the reconstructed 8×8 block.

I. Video Codec Standards.

Over the last two decades, various video coding and decoding standardshave been adopted, including the H.261, H.262 (MPEG-2) and H.263 seriesof standards and the MPEG-1 and MPEG-4 series of standards. Morerecently, the H.264 standard (sometimes referred to as AVC or JVT) andVC-1 standard have been adopted. For additional details, seerepresentative versions of the respective standards.

Such a standard typically defines options for the syntax of an encodedvideo bit stream according to the standard, detailing the parametersthat must be in the bit stream for a video sequence, picture, block,etc. when particular features are used in encoding and decoding. Thestandards also define how a decoder conforming to the standard shouldinterpret the bit stream parameters—the bit stream semantics. In manycases, the standards provide details of the decoding operations thedecoder should perform to achieve correct results. Often, however, thelow-level implementation details of the operations are not specified, orthe decoder is able to vary certain implementation details to improveperformance, so long as the correct decoding results are still achieved.

During development of a standard, engineers may concurrently generatereference software, sometimes called verification model software or JMsoftware, to demonstrate rate-distortion performance advantages of thevarious features of the standard. Typical reference software provides a“proof of concept” implementation that is not algorithmically optimizedor optimized for a particular hardware platform. Moreover, typicalreference software does not address multithreading implementationdecisions, instead assuming a single threaded implementation for thesake of simplicity.

II. Acceleration of Video Decoding and Encoding.

While some video decoding and encoding operations are relatively simple,others are computationally complex. For example, inverse frequencytransforms, fractional sample interpolation operations for motioncompensation, in-loop deblock filtering, post-processing filtering,color conversion, and video re-sizing can require extensive computation.This computational complexity can be problematic in various scenarios,such as decoding of high-quality, high-bit rate video (e.g., compressedhigh-definition video). In particular, decoding tasks according to morerecent standards such as H.264 and VC-1 can be computationally intensiveand consume significant memory resources.

Some decoders use video acceleration to offload selected computationallyintensive operations to a graphics processor. For example, in someconfigurations, a computer system includes a primary central processingunit (“CPU”) as well as a graphics processing unit (“GPU”) or otherhardware specially adapted for graphics processing. A decoder uses theprimary CPU as a host to control overall decoding and uses the GPU toperform simple operations that collectively require extensivecomputation, accomplishing video acceleration.

In a typical software architecture for video acceleration during videodecoding, a video decoder controls overall decoding and performs somedecoding operations using a host CPU. The decoder signals controlinformation (e.g., picture parameters, macroblock parameters) and otherinformation to a device driver for a video accelerator (e.g., with GPU)across an acceleration interface.

The acceleration interface is exposed to the decoder as an applicationprogramming interface (“API”). The device driver associated with thevideo accelerator is exposed through a device driver interface (“DDI”).In an example interaction, the decoder fills a buffer with instructionsand information then calls a method of an interface to alert the devicedriver through the operating system. The buffered instructions andinformation, opaque to the operating system, are passed to the devicedriver by reference, and video information is transferred to GPU memoryif appropriate. While a particular implementation of the API and DDI maybe tailored to a particular operating system or platform, in some cases,the API and/or DDI can be implemented for multiple different operatingsystems or platforms.

In some cases, the data structures and protocol used to parameterizeacceleration information are conceptually separate from the mechanismsused to convey the information. In order to impose consistency in theformat, organization and timing of the information passed between thedecoder and device driver, an interface specification can define aprotocol for instructions and information for decoding according to aparticular video decoding standard or product. The decoder followsspecified conventions when putting instructions and information in abuffer. The device driver retrieves the buffered instructions andinformation according to the specified conventions and performs decodingappropriate to the standard or product. An interface specification for aspecific standard or product is adapted to the particular bit streamsyntax and semantics of the standard/product.

Given the critical importance of video compression and decompression todigital video, it is not surprising that compression and decompressionare richly developed fields. Whatever the benefits of previoustechniques and tools, however, they do not have the advantages of thefollowing techniques and tools.

SUMMARY

In summary, techniques and tools are described for various aspects ofvideo decoder implementations. These techniques and tools help, forexample, to increase decoding speed to facilitate real time decoding, orto reduce computational complexity in scenarios such as those withprocessing power constraints and/or delay constraints.

According to one aspect of the techniques and tools described herein, adecoder receives a coded video bit stream including multiple pictures inserial coded order. The decoder decodes the multiple pictures with oneor more central processing units (“CPUs”) and a graphics processing unit(“GPU”). The CPU(s) perform multiple decoding operations (e.g., pictureextent discovery, entropy decoding). The GPU performs multiple decodingoperations (e.g., intra prediction, motion compensation, loop filtering)asynchronously from the multiple decoding operations performed by theCPU(s). For a given picture, the GPU can perform at least some of itsdecoding operations in parallel for multiple blocks with the givenpicture. The CPU(s) can generate tasks and insert them in a commandbuffer; one at a time, the GPU can extract primitives corresponding tothe tasks and execute the primitives in serial order. The CPU(s) canalso generate markers and insert them into a command buffer, where amarker indicates completion of decoding of a corresponding picture; theGPU can trigger the marker upon reaching the marker in the commandbuffer, resulting in copying of the corresponding picture into an outputbuffer and marking it as available for reference in a decoded picturebuffer.

According to another aspect, a decoder receives a coded video bit streamthat includes encoded video for multiple pictures in serial coded order.The decoder scans ahead in the bit stream to determine multiple resourceusage patterns (e.g., memory partitions, image array slot assignments)for the multiple pictures, tracking the multiple resource usagepatterns. The tracked patterns include at least some inconsistentresource usage patterns in flight during at least part of decoding. Thedecoder can also track commands for decoding operations in a commandqueue, which represents the multiple resource usage patterns. Thedecoder performs decoding operations on the multiple pictures in serialcoded order with a GPU.

According to another aspect, a decoder organizes multiple blocks asmultiple waves. Each of the multiple waves includes one or more of theblocks. For example, the decoder groups as a first wave a first set ofblocks having no dependencies on other blocks, groups as a second wave asecond set of blocks having no dependencies other than dependencies onthe first set, groups as a third wave a third set of blocks having nodependencies other than dependencies on the first and second sets, andso on. The waves can de determined dynamically or statically. With aGPU, the decoder performs decoding operations (e.g., intra prediction,loop filtering) on the multiple blocks on a wave-by-wave basis. For atleast one of the multiple waves, the decoder (with GPU) processes blockswithin the wave in parallel.

In other embodiments, a decoder implements one or more of theinnovations stated in the table at the end of the application.

The various techniques and tools can be used in combination orindependently. Additional features and advantages will be made moreapparent from the following detailed description of differentembodiments, which proceeds with reference to the accompanying figures.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a generalized example of asuitable computing environment in which several of the describedembodiments may be implemented.

FIG. 2 is a block diagram of a generalized video decoder in conjunctionwith which several of the described embodiments may be implemented.

FIG. 3 is a diagram illustrating example layered data structures formultithreaded decoding.

FIG. 4 is a diagram illustrating example stages of multithreadeddecoding.

FIG. 5 is a flowchart illustrating a generalized technique for pictureextent discovery in multithreaded decoding.

FIG. 6 is a diagram illustrating an example picture command queue inmultithreaded decoding.

FIG. 7 is a flowchart illustrating a generalized technique for removingpicture commands from a picture command queue in multithreaded decoding.

FIG. 8 is a diagram illustrating example picture command queuemanagement processing in different decoding tasks.

FIG. 9 is a flowchart illustrating a generalized technique for creatinga task dependency graph for segments of macroblocks.

FIG. 10 is a diagram illustrating an example task dependency graph forpictures.

FIGS. 11 and 12 are flowcharts illustrating generalized techniques forrecovery mechanisms in decoding.

FIG. 13 is a flowchart illustrating a generalized technique for usingone or more tables to determine neighbor availability during decoding.

FIG. 14 is a flowchart illustrating a generalized technique for using astate machine and one or more tables to determine neighbor availabilityduring decoding of a progressive or field picture.

FIG. 15 is a chart showing MB neighbors of a current MB.

FIG. 16 is a diagram illustrating a state machine used in MB neighboravailability determinations.

FIGS. 17, 18 and 20 are pseudocode listings for example tables used intable-based neighbor availability determinations.

FIG. 19 is a diagram illustrating an example neighbor context bit vectorused in table-based neighbor availability determinations.

FIG. 21 is a pseudocode listing for reference code for a corecontext-adaptive binary arithmetic decoding function.

FIGS. 22a, 22b , 23 and 24 are flowcharts for context-adaptive binaryarithmetic decoding innovations.

FIG. 25 is a diagram illustrating an example framework for switchingbetween playback modes.

FIG. 26 is a flowchart illustrating a generalized technique forswitching between playback modes.

FIG. 27 is a flowchart illustrating a generalized technique forreduced-latency switching to a trick play mode.

FIG. 28 is a diagram illustrating layers of software implementing anexample picture dropping approach.

FIG. 29 is a flowchart illustrating a generalized technique forswitching picture dropping modes during playback.

FIG. 30 is a diagram illustrating dependencies for an example group ofpictures.

FIG. 31 is a flowchart illustrating a generalized technique for managinga DPB while selectively dropping pictures.

FIGS. 32 and 33 are tables showing functions for computing collocatedmacroblock information in different situations.

FIG. 34 is a diagram illustrating an example task dependency graphincluding a task for computing collocated macroblock information.

FIG. 35 is a flowchart illustrating a generalized technique forcomputing slice-level and macroblock-level collocated macroblockinformation.

FIGS. 36 and 37 are diagrams illustrating example data structures forpacking entropy decoded transform coefficients.

FIG. 38 is a diagram illustrating thread-specific dynamically growingbuffers for packed coefficient levels.

FIG. 39 is a diagram illustrating field pictures stored in a framememory buffer.

FIG. 40 is a diagram of a GPU architecture used in some embodiments.

FIG. 41 is a diagram of a shader functional model used in someembodiments.

FIG. 42 is a diagram of an example of separate processing paths fordifferent inverse transform types.

FIG. 43 is a flowchart of a generalized technique for performing inversetransforms in separate passes for different inverse transform types.

FIG. 44 is a diagram illustrating example input and output block ordersfor a macroblock.

FIG. 45 is a pseudocode listing for an example inverse transformimplementation.

FIG. 46 is a flowchart of a generalized technique for performing inversequantization in separate passes for different inverse quantizationtypes.

FIG. 47 is a diagram of sample positions referenced in exampleinterpolation operations.

FIG. 48 is a diagram of an example of separate processing paths fordifferent motion vector types.

FIG. 49 is a flowchart of a generalized technique for performing motioncompensation in separate passes for different motion vector types.

FIG. 50 is a flowchart of a generalized technique for performing intraprediction on a wave-by-wave basis.

FIG. 51 is a flowchart of a generalized technique for organizing dynamicwaves for intra prediction.

FIG. 52 is a diagram of a data structure for tracking how blocks areorganized in waves.

FIG. 53 is a flowchart of a generalized technique for merging luma wavesand chroma waves.

FIG. 54 is a chart illustrating sample positions referenced inrefactored intra prediction operations.

FIG. 55 is a flowchart of a generalized technique for performing loopfiltering in multiple passes.

FIG. 56 is a flowchart of a generalized technique for performing loopfiltering on a wave-by-wave basis.

FIGS. 57 and 58 are diagrams illustrating portions filtered in differentloop filtering passes.

FIG. 59 is a flowchart of a generalized technique for adapting loopfiltering in response to changes in decoding performance.

DETAILED DESCRIPTION

The present application relates to innovations in implementations ofvideo decoders. Many of these innovations reduce decoding complexityand/or increase decoding speed to improve decoding performance. Theseinnovations include:

-   -   1. A decoder framework with layered data structures for        multithreading implementations.    -   2. Picture extent discovery for multithreading implementations.    -   3. A picture command queue for multithreading implementations.    -   4. An improved task scheduler for multithreading        implementations.    -   5. A decoder that can run in different threading modes,        including single threaded mode, multithreaded with CPU mode, and        1 or 2 CPU threads+GPU mode.    -   6. An error handling and recovery framework providing strong        error resilience.    -   7. Efficient determination of neighbor availability for        operations such as context modeling and intra prediction, using        pre-designed tables and/or state machines, for various types of        pictures.    -   8. CABAC decoding innovations that speed up CABAC decoding        and/or more efficiently use memory.    -   9. Improved computation of collocated information for direct        mode macroblocks in B slices.    -   10. Reduction of memory consumption in multithreading        implementations.    -   11. Efficient implementations of trick play modes.    -   12. An efficient picture dropping approach for quality        adjustment.    -   13. An interface for communication between CPU(s) and GPU.    -   14. Inverse transforms for GPU implementations.    -   15. Inverse quantization for GPU implementations.    -   16. Fractional interpolation for GPU implementations.    -   17. Intra prediction using waves for GPU implementations.    -   18. Loop filtering using waves for GPU implementations.    -   19. Efficient memory usage for GPU implementations.    -   20. Efficient film grain noise generation for GPU        implementations.    -   21. Adaptive loop filtering with quality feedback for GPU        implementations.    -   22. Asynchronous decoding by GPU and CPU(s).    -   23. A GPU command buffer filled by CPU(s) and emptied by GPU.    -   24. A synchronization interface between GPU and CPU(s).

For example, in order to decode video in real time, the decodingprocesses of a standard such as H.264 or VC-1 are analyzed to identifyopportunities for algorithmic improvements. Specific examples ofidentified algorithmic improvements are described below. The decodingprocesses are also analyzed to identify opportunities forhardware-specific performance improvements. Additional improvements formultithreading implementations further speed up the decoding processing,and still other improvements help reduce memory consumption duringdecoding.

Collectively, these improvements are at times loosely referred to as“optimizations.” As used conventionally and as used herein, the term“optimization” means an improvement that is deemed to provide a goodbalance of performance in a particular scenario or platform, consideringcomputational complexity, memory use, processing speed, and/or otherfactors. Use of the term “optimization” does not foreclose thepossibility of further improvements, nor does it foreclose thepossibility of adaptations for other scenarios or platforms.

Other innovations provide new decoder-side features to improve theplayback experience for end users. For example, the present applicationdescribes efficient implementations for trick play modes (e.g., fastforward, fast rewind) and recovery modes using picture dropping.

With these innovations, efficient decoder implementations have beenprovided for diverse platforms. The implementations include mediaplayers for gaming consoles with complex, special-purpose hardware andgraphics capabilities, personal computers, and set-top boxes/digitalvideo receivers.

Various alternatives to the implementations described herein arepossible. For example, certain techniques described with reference toflowchart diagrams can be altered by changing the ordering of stagesshown in the flowcharts, by repeating or omitting certain stages, etc.,while achieving the same result. As another example, although someimplementations are described with reference to specific macroblockformats, other formats also can be used. As another example, whileseveral of the innovations described below are presented in terms ofH.264/AVC decoding examples, the innovations are also applicable toother types of decoders (e.g., MPEG-2, VC-1) that provide or support thesame or similar decoding features.

The various techniques and tools described herein can be used incombination or independently. For example, although flowcharts in thefigures typically illustrate techniques in isolation from other aspectsof decoding, the illustrated techniques in the figures can typically beused in combination with other techniques (e.g., shown in otherfigures). Different embodiments implement one or more of the describedtechniques and tools. Some of the techniques and tools described hereinaddress one or more of the problems noted in the Background. Typically,a given technique/tool does not solve all such problems, however.Rather, in view of constraints and tradeoffs in decoding time and/orresources, the given technique/tool improves performance for aparticular implementation or scenario.

I. Computing Environment.

FIG. 1 illustrates a generalized example of a suitable computingenvironment (100) in which several of the described embodiments may beimplemented. The computing environment (100) is not intended to suggestany limitation as to scope of use or functionality, as the techniquesand tools may be implemented in diverse general-purpose orspecial-purpose computing environments.

With reference to FIG. 1, the computing environment (100) includes atleast one CPU (110) and associated memory (120) as well as at least oneGPU or other co-processing unit (115) and associated memory (125) usedfor video acceleration. In FIG. 1, this most basic configuration (130)is included within a dashed line. The processing unit (110) executescomputer-executable instructions and may be a real or a virtualprocessor. In a multi-processing system, multiple processing unitsexecute computer-executable instructions to increase processing power. Ahost encoder or decoder process offloads certain computationallyintensive operations (e.g., fractional sample interpolation for motioncompensation, in-loop deblock filtering) to the GPU (115). The memory(120, 125) may be volatile memory (e.g., registers, cache, RAM),non-volatile memory (e.g., ROM, EEPROM, flash memory, etc.), or somecombination of the two. The memory (120, 125) stores software (180) fora decoder implementing one or more of the decoder innovations describedherein.

A computing environment may have additional features. For example, thecomputing environment (100) includes storage (140), one or more inputdevices (150), one or more output devices (160), and one or morecommunication connections (170). An interconnection mechanism (notshown) such as a bus, controller, or network interconnects thecomponents of the computing environment (100). Typically, operatingsystem software (not shown) provides an operating environment for othersoftware executing in the computing environment (100), and coordinatesactivities of the components of the computing environment (100).

The storage (140) may be removable or non-removable, and includesmagnetic disks, magnetic tapes or cassettes, CD-ROMs, DVDs, or any othermedium which can be used to store information and which can be accessedwithin the computing environment (100). The storage (140) storesinstructions for the software (180).

The input device(s) (150) may be a touch input device such as akeyboard, mouse, pen, or trackball, a voice input device, a scanningdevice, or another device that provides input to the computingenvironment (100). For audio or video encoding, the input device(s)(150) may be a sound card, video card, TV tuner card, or similar devicethat accepts audio or video input in analog or digital form, or a CD-ROMor CD-RW that reads audio or video samples into the computingenvironment (100). The output device(s) (160) may be a display, printer,speaker, CD-writer, or another device that provides output from thecomputing environment (100).

The communication connection(s) (170) enable communication over acommunication medium to another computing entity. The communicationmedium conveys information such as computer-executable instructions,audio or video input or output, or other data in a modulated datasignal. A modulated data signal is a signal that has one or more of itscharacteristics set or changed in such a manner as to encode informationin the signal. By way of example, and not limitation, communicationmedia include wired or wireless techniques implemented with anelectrical, optical, RF, infrared, acoustic, or other carrier.

The techniques and tools can be described in the general context ofcomputer-readable media. Computer-readable media are any available mediathat can be accessed within a computing environment. By way of example,and not limitation, with the computing environment (100),computer-readable media include memory (120), storage (140),communication media, and combinations of any of the above.

The techniques and tools can be described in the general context ofcomputer-executable instructions, such as those included in programmodules, being executed in a computing environment on a target real orvirtual processor. Generally, program modules include routines,programs, libraries, objects, classes, components, data structures, etc.that perform particular tasks or implement particular abstract datatypes. The functionality of the program modules may be combined or splitbetween program modules as desired in various embodiments.Computer-executable instructions for program modules may be executedwithin a local or distributed computing environment.

For the sake of presentation, the detailed description uses terms like“decide,” “make” and “get” to describe computer operations in acomputing environment. These terms are high-level abstractions foroperations performed by a computer, and should not be confused with actsperformed by a human being. The actual computer operations correspondingto these terms vary depending on implementation.

II. Example Organization of Video Frames.

For progressive video, lines of a video frame contain samples startingfrom one time instant and continuing through successive lines to thebottom of the frame. An interlaced video frame consists of two scans—onefor the even lines of the frame (the top field) and the other for theodd lines of the frame (the bottom field).

A progressive video frame can be divided into 16×16 macroblocks. For4:2:0 format, a 16×16 macroblock includes four 8×8 blocks (Y0 throughY3) of luma (or brightness) samples and two 8×8 blocks (Cb, Cr) ofchroma (or color component) samples, which are collocated with the fourluma blocks but half resolution horizontally and vertically.

An interlaced video frame includes alternating lines of the top fieldand bottom field. The two fields may represent two different timeperiods or they may be from the same time period. When the two fields ofa frame represent different time periods, this can create jaggedtooth-like features in regions of the frame where motion is present.

Therefore, interlaced video frames can be rearranged according to afield structure, with the odd lines grouped together in one field, andthe even lines grouped together in another field. This arrangement,known as field coding, is useful in high-motion pictures. For aninterlaced video frame organized for encoding/decoding as separatefields, each of the two fields of the interlaced video frame ispartitioned into macroblocks. The top field is partitioned intomacroblocks, and the bottom field is partitioned into macroblocks. Inthe luma plane, a 16×16 macroblock of the top field includes 16 linesfrom the top field, and a 16×16 macroblock of the bottom field includes16 lines from the bottom field, and each line is 16 samples long.

On the other hand, in stationary regions, image detail in the interlacedvideo frame may be more efficiently preserved without rearrangement intoseparate fields. Accordingly, frame coding (at times referred to codingwith MBAFF pictures) is often used in stationary or low-motioninterlaced video frames. An interlaced video frame organized forencoding/decoding as a frame is also partitioned into macroblocks. Inthe luma plane, each macroblock includes 8 lines from the top fieldalternating with 8 lines from the bottom field for 16 lines total, andeach line is 16 samples long. Within a given macroblock, the top-fieldinformation and bottom-field information may be coded jointly orseparately at any of various phases—the macroblock itself may befield-coded or frame-coded.

III. Generalized Video Decoder.

FIG. 2 is a block diagram of a generalized video decoder (200) inconjunction with which several described embodiments may be implemented.A corresponding video encoder (not shown) may also implement one or moreof the described embodiments.

The relationships shown between modules within the decoder (200)indicate general flows of information in the decoder; otherrelationships are not shown for the sake of simplicity. In particular,while a decoder host performs some operations of modules of the decoder(200), a video accelerator performs other operations (such as inversefrequency transforms, fractional sample interpolation, motioncompensation, in-loop deblocking filtering, color conversion,post-processing filtering and/or picture re-sizing). For example, thedecoder (200) passes instructions and information to the videoaccelerator as described in “Microsoft DirectX VA: Video AccelerationAPI/DDI,” version 1.01, a later version of DXVA or another accelerationinterface. In general, once the video accelerator reconstructs videoinformation, it maintains some representation of the video informationrather than passing information back. For example, after a videoaccelerator reconstructs an output picture, the accelerator stores it ina picture store, such as one in memory associated with a GPU, for use asa reference picture. The accelerator then performs in-loop deblockfiltering and fractional sample interpolation on the picture in thepicture store.

In some implementations, different video acceleration profiles result indifferent operations being offloaded to a video accelerator. Forexample, one profile may only offload out-of-loop, post-decodingoperations, while another profile offloads in-loop filtering, fractionalsample interpolation and motion compensation as well as thepost-decoding operations. Still another profile can further offloadfrequency transform operations. In still other cases, different profileseach include operations not in any other profile.

Returning to FIG. 2, the decoder (200) processes video pictures, whichmay be video frames, video fields or combinations of frames and fields.The bit stream syntax and semantics at the picture and macroblock levelsmay depend on whether frames or fields are used. The decoder (200) isblock-based and uses a 4:2:0 macroblock format for frames. For fields,the same or a different macroblock organization and format may be used.8×8 blocks may be further sub-divided at different stages.Alternatively, the decoder (200) uses a different macroblock or blockformat, or performs operations on sets of samples of different size orconfiguration.

The decoder (200) receives information (295) for a compressed sequenceof video pictures and produces output including a reconstructed picture(205) (e.g., progressive video frame, interlaced video frame, or fieldof an interlaced video frame). The decoder system (200) decompressespredicted pictures and key pictures. For the sake of presentation, FIG.2 shows a path for key pictures through the decoder system (200) and apath for predicted pictures. Many of the components of the decodersystem (200) are used for decompressing both key pictures and predictedpictures. The exact operations performed by those components can varydepending on the type of information being decompressed.

A demultiplexer (290) receives the information (295) for the compressedvideo sequence and makes the received information available to theentropy decoder (280). The entropy decoder (280) entropy decodesentropy-coded quantized data as well as entropy-coded side information,typically applying the inverse of entropy encoding performed in theencoder. A motion compensator (230) applies motion information (215) toone or more reference pictures (225) to form motion-compensatedpredictions (235) of sub-blocks, blocks and/or macroblocks of thepicture (205) being reconstructed. One or more picture stores storepreviously reconstructed pictures for use as reference pictures.

The decoder (200) also reconstructs prediction residuals. An inversequantizer (270) inverse quantizes entropy-decoded data. An inversefrequency transformer (260) converts the quantized, frequency domaindata into spatial domain video information. For example, the inversefrequency transformer (260) applies an inverse block transform tosub-blocks and/or blocks of the frequency transform coefficients,producing sample data or prediction residual data for key pictures orpredicted pictures, respectively. The inverse frequency transformer(260) may apply an 8×8, 8×4, 4×8, 4×4, or other size inverse frequencytransform.

For a predicted picture, the decoder (200) combines reconstructedprediction residuals (245) with motion compensated predictions (235) toform the reconstructed picture (205). A motion compensation loop in thevideo decoder (200) includes an adaptive deblocking filter (223). Thedecoder (200) applies in-loop filtering (223) to the reconstructedpicture to adaptively smooth discontinuities across block/sub-blockboundary rows and/or columns in the picture. The decoder stores thereconstructed picture in a picture buffer (220) for use as a possiblereference picture.

Depending on implementation and the type of compression desired, modulesof the decoder can be added, omitted, split into multiple modules,combined with other modules, and/or replaced with like modules. Inalternative embodiments, encoders or decoders with different modulesand/or other configurations of modules perform one or more of thedescribed techniques. Specific embodiments of video decoders typicallyuse a variation or supplemented version of the generalized decoder(200).

For the sake of presentation, the following table provides exampleexplanations for acronyms and selected shorthand terms used herein.

Term Explanation block arrangement (in general, having any size) ofsample values for pixel data or residual data, for example, includingthe possible blocks in H.264/AVC- 4 × 4, 4 × 8, 8 × 4, 8 × 8, 8 × 16, 16× 8, and 16 × 16 CABAC context adaptive binary arithmetic coding CAVLCcontext adaptive variable length coding DPB decoded picture buffer EDentropy decoding FIFO first in first out INTRA spatial intra-predictionLF loop filtering MB megabyte OR macroblock, depending on context; amacroblock is, e.g., 16 × 16 arrangement of sample values for luma withassociated arrangements of sample values for chroma MBAFF macroblockadaptive frame field MC motion compensation MMCO memory managementcontrol operation NALU network abstraction layer unit PED picture extentdiscovery PICAFF picture adaptive frame field PPS picture parameter setPROG progressive SEI supplemental enhancement information SIMD singleinstruction multiple data SPS sequence parameter set stage (of a set ofdifferent passes/steps to decode a picture, decoding) such as PED, ED,MC and so on sub-block a partition of a sub-MB, e.g., 8 × 4, 4 × 8 or 4× 4 block or other size block sub-MB a partition of an MB, e.g., 16 × 8,8 × 16 or 8 × 8 block or other size block; in some contexts, the termsub-MB also indicates sub-blocks task a stage plus input data wave a setof portions of a picture (e.g., a diagonal set of macroblocks in thepicture) such that each portion within one wave can be processed inparallel, without dependencies on the other portions within the samewave; a picture can then be processed as a sequence of waves where eachwave is dependent on the data resulting from processing the precedingwaves

IV. Multithreading Design Innovations for a Video Decoder.

In some embodiments, a decoder uses one or more multithreadinginnovations when decoding video. Collectively, the multithreadinginnovations efficiently find opportunities for parallel processing inthe bit stream and support fine-grained task scheduling in the decoding.

In contrast, naïve implementations of the reference code for the H.264standard are single threaded and synchronous. A decoder parses the bitstream for a picture, initializes structures for the picture, decodesthe pictures, and updates the decoded picture buffer, then moves on tothe next picture. This is inefficient for many modern architectures andimpractical for many H.264 decoding scenarios.

Previous multithreading implementations provide coarse-grainedscheduling or only allow for parallel processing for entropy decoding.These implementations do not effectively look ahead in a bit stream tofind other opportunities for parallel processing in decoding, nor dothey support finer grained scheduling for other types of operations.

This section describes flexible multithreading models that incorporatedifferent multithreading implementations. A PED module finds completepictures in a bit stream, identifies opportunities for parallelprocessing, and simulates a “live” DPB as in a single threadedimplementation so as to help order picture commands. A picture commandqueue facilitates pipeline picture decoding, potentially storing picturecommands for pictures as those pictures are being decoded. A taskscheduler distributes available tasks to different threads according toone of several available scheduling heuristics. An available task canprocess data for a picture, slice or other segment (collection ofmacroblocks). The multithreading models can be applied in a CPU+GPUarchitecture, multiple CPU architecture, or multiple CPU+GPUarchitecture.

A. Overall Multithreading Framework.

1. Layered Data Structures.

The data structures used in multithreading are an important aspect ofthe overall design. In some embodiments, a multithreaded decoder useslayered data structures (300) as shown in FIG. 3. As FIG. 3 shows, theparameters of an encoded video bit stream are organized intolayered/hierarchical data structures generally according to theirlifetime in the decoding process.

The Decoder structure (310) (stMSH264Decoder_tag) holds parameters anddata structures for the decoder. These parameters and structuresbasically have the decoder's lifetime. For example, it holds parametersand structures as follows.

Structure/Parameter Explanation struct threading holds the parametersfor threading, such as pumped or not (pumpedDecoder), pumped PED runningor not (bPEDTaskRunning), and so on. struct ped holds the necessaryparameters for the process of PED, such as the temporary slice headerparameters, temporal NALU parameters, parameters for field picturepairing, live DPB and so on. struct pools holds different memory pools,such as PictureHolder pool, neighbor availability table pool,SliceHolder pool, and so on. struct parameters for dependency graphstTaskDependencyGraph_tag struct Manage_PIC_FIFO parameters for picturecommand FIFO. struct stOutFrm parameters for circular output buffer.timing stamp parameters parameters for time stamps for pictures.

The parameters in the Decoder structure (310) can be accessed by workingthreads. The parameters are based upon, for example, sequenceparameters, and the parameters may change when a new SPS is processed.

A PictureHolder structure (320, 322) (stPictureHolder_tag) holdstemporary parameters for decoding a picture and references otherstructures used in decoding the picture. Once a picture is decoded, someof the temporary picture parameters may be discarded. The decoded sampledata for the picture (along with certain parameters used for referencepurposes) are stored in a StorablePicture structure (340). For example,the picture parameters are divided into several categories. Pointersthat point to live instances in decoder structure includepstStorablePicPool, pstMBOffsetTableVar, pstMBOffsetTableMBAFFVar andpPPS. Cache pointers that point to the real memories insideStorablePicture (340) include imgY, imgUV, pcRefldx1, pnMv0. Pictureparameters for the picture in PictureHolder (320, 322) includePicWidthlnMbs, field_pic_flag, bottom_used_for_reference. Thebuffers/arrays are shared by different slices in the picture—these maybe compressed buffer pointers, stream buffer pointers, slice parameterarrays (rgSliceOpt), macroblock arrays (mb_data_opt). A SliceHolderXarray holds all the Sliceholders (330, 332) in this picture.

A StorablePicture structure (340) holds decoded pixel data, sideinformation, and parameters for a reference picture and DPB management.The lifetime of a StorablePicture structure (340) is different from thatof a PictureHolder structure (320, 322). A PictureHolder structure (320,322) for a picture can be deallocated when the picture is decoded, sincethe parameters in the PictureHolder structure (320, 322) are used fordecoding. The parameters and data in a StorablePicture structure (340)are valid until the corresponding picture is deleted from the decoder.For example, the StorablePicture structure (340) stores decoded picturedata imgY, imgUV, ref_idx, pnMv0, which are used for the purpose ofreference. It also stores DPB management parameters frame_num,long_term_pic_num, non_existing. The values of these DPB parameters canbe changed during DPB management. A private copy is stored in aPictureHolder structure (320, 322) for some DPB management parameters ifthe parameters are needed for the decoding of the picture itself. Forexample, frame_used_for_reference, top_used_for_reference, . . . are theprivate copies of used_for_reference. The StorablePicture structure(340) also stores time stamp and display parameters (e.g.,uiAspectRatio, bPicStructPresentFlag, timeStampFlag, bIsDiscontinuity)and parameters used for picture skipping (e.g., bSkipDecodingPicture,bIPicture, bBPicture).

A SliceHolder structure (330, 332) (stSliceHolder_tag) holds thetemporary parameters, buffers and arrays for the decoding of one slice.Once the slice is decoded, the parameters in this structure can bede-allocated. For example, a SliceHolder structure (330, 332) storesslice parameters (e.g., start_mb_nr, iSliceType, current_slice_nr),buffers (e.g., pintraMBPosLevelBase, pcITransBuffers), and arrays (e.g.,mvscale, listX, listXsize).

A macroblock structure (350) (macroblock_opt) holds the temporaryparameters to decode one macroblock. A PictureHolder structure (320,322) holds macroblock structures for the macroblocks inside a picture.In some implementations, the macroblock structure is highly compressedin that empty space in certain bytes is avoided by assigning differentmeanings to different bits within the bytes.

Alternatively, the decoder uses different data structures formultithreading. For example, the decoder uses data structures with otherand/or additional parameters or data.

2. Code Paths.

In some embodiments, a multithreaded decoder uses different code pathsfor different picture formats. For example, an H.264 decoder includesdifferent code paths for PROG pictures, PICAFF pictures, and MBAFFpictures. The following table shows different picture formats fordifferent combinations of the parameters frame_mbs_only_flag,mb_adaptive_frame_field_flag and field_pic_flag for an H.264 decoder.

frame_mbs_only_flag mb_adaptive_frame_field_flag field_pic_flag pictureformat 1 x x progressive (A) 0 0 0 progressive (B) 0 0 1 field picture(C) 0 1 0 mbaff frame (D) 0 1 1 field picture (E)

The PROG path processes pictures of format A, the PICAFF path processespictures of format B or C, and the MBAFF path processes pictures offormat D or E. The H.264 decoder also supports two different kinds ofentropy encoding—CABAC and CAVLC. Since different picture formats oftenuse different optimization techniques, the decoding process fordifferent picture formats is separated into different code paths, i.e.PROG code path, PICAFF code path, and MBAFF code path. In each codepath, entropy decoding can be CABAC or CAVLC.

Alternatively, the decoder uses more or fewer code paths.

3. Task Separation.

In some embodiments, a multithreaded decoder separates decodingprocesses into tasks as follows. FIG. 4 shows stages (400) of decodingfor one picture in some implementations. The stages (400) include apicture extent discovery (“PED”) stage (410) for finding andinitializing complete pictures; an entropy decoder (“ED”) stage (420)for entropy decoding transform coefficients, motion vectors and otherside information with CABAC decoding or CAVLC decoding; a motion vectorsetup (“MV setup”) stage (425) for reconstructing motion vectors in PBor B pictures; a motion-compensated prediction (“MC”) stage (430) forreconstructing inter-coded content using motion compensation; anintra-prediction (“INTRA”) stage (440) for reconstructing intra-codedcontent using spatial intra prediction, and a loop filtering (“LF”)stage (450) for performing deblock filtering and other processing ondecoded pictures. Not all pictures are decoded with all stages. Forexample, the MC stage is not used for I pictures, and the INTRA stage isnot used when decoding some P pictures.

Alternatively, the decoder partitions decoding processes into otherand/or different stages, for example, by combining smaller tasks intolarger ones. For example, for some architectures, the decoder putsdecoding processes for MC, INTRA and LF into a single task. Or, apost-processing stage (“POST”) is used for processing such as theaddition of film grain noise to pictures before display.

4. Modules for Multithreading.

In some embodiments, a multithreaded decoder uses modules thatfacilitate multithreading by finding opportunities for fine-grainedparallel processing. For example, for some implementations of H.264decoders, aside from the modules conventionally used for decoding, thesemodules include a picture extent discovery module, a picture commandqueue management module, and a task scheduler.

The PED module finds a complete picture from the bit stream andinitializes the parameters and data structures that will be used fordecoding the picture. The PED module populates some of the initializedparameters and structures with parameters parsed from the bit stream.The PED module also enters the initialized (but as yet un-decoded)picture into a live DPB, which facilitates multithreaded decoding.

The picture command queue module manages picture commands such as outputcommands and delete commands which are stored in a command queue (e.g.,a FIFO queue). DPB management routines (e.g., in the PED module) producepicture commands associated with a dependent picture, which is aninitialized but un-decoded picture in the DPB. When the dependentpicture is decoded, the associated commands for the picture can beexecuted. The command queue thus records commands associated withcompletion of decoding for the dependent picture, and the commands areexecuted when the dependent picture is decoded, which facilitatessimulation of a live DPB from a typical single threaded decodingscenario.

When a working thread is ready (out of waiting/sleep state), the taskscheduler finds a ready task, runs the ready task with the workingthread, updates the dependency graph on the completion of the task, putsready tasks into a ready queue, and returns. To find the ready task, thescheduler can use a task dependency graph that facilitates fine-grainedmultithreading or some other threading model(s) dependent on the decodersettings.

Alternatively, a multithreaded decoder includes other and/or additionalmodules.

B. Picture Extent Discovery with Simulation of Live DPB.

Video decoding according to recent standards (e.g., H.264, VC-1) can betoo computationally intensive for a single hardware thread. Inparticular, processes like CABAC and loop filtering can be performancebottlenecks.

In some embodiments, a decoder includes a PED module that parses encodedvideo bit streams to discover segments (e.g., groups of macroblocks,slices, pictures) that can be independently decoded. For example, thePED module finds picture boundaries and logs data in a lightweightlook-ahead process, initializing parameters and data structures forpictures encountered in the bit stream, thereby providing a “snapshot”of upcoming segments and their dependencies that a task scheduler andDPB manager can use in multithreaded decoding. The look-ahead process isintrinsically serial, in that the decoder traverses the serial encodedvideo bit stream, but it results in the identification and organizationof elements that can be decoded in parallel.

FIG. 5 shows a technique (500) for performing picture extent discovery.A decoder such as the one described above with reference to FIG. 2 orother decoder performs the technique (500).

For a given picture, the decoder (e.g., a PED module in the decoder)parses (510) parameters for the picture from the encoded video bitstream. For example, the decoder parses SPS, PPS, picture layer andslice layer parameters for the picture. Alternatively, the decoderparses other and/or additional parameters from the bit stream.

The decoder initializes (520) structures for holding parameters and datafor the picture. For example, the decoder allocates memory and createslayered data structures for the picture as described above, includingdata structures for the picture, and one or more slices in the picture.The decoder can populate at least some of the data structures withparameters parsed from the bit stream. For other structures, the decoderjust creates placeholders for later defined values—at the PED stage, itmay suffice to determine which pictures are going to be decoded anddetermine what the values of certain parameters are, without referencingall pixel data. Alternatively, the decoder initializes other structuresfor the picture.

The decoder also tracks (530) dependencies for the picture. For example,the decoder identifies and logs stages of decoding for the picture thatdepend on the completion of other stages of decoding for the picture orthat depend on the completion of stages of decoding for other pictures.The decoder tracks the dependencies, for example, in a task dependencygraph that includes as nodes decoding tasks for segments of the pictureand other pictures, and includes as edges the dependencies betweentasks. Dependencies can be logged on a picture-by-picture basis,slice-by-slice basis, segment-by-segment basis, or other basis, forexample, decided by the threading model. Alternatively, the decodertracks dependencies using another type of tracking structure.

The decoder determines (540) whether to continue with the next pictureor end. If the decoder continues, it parses (510) parameters for thenext picture. For multithreaded decoding, the decoder typically scansahead in the bit stream for multiple pictures before decoding begins forthe scanned pictures. In this way, the decoder can more efficiently useavailable processing resources and make more informed task schedulingdecisions. In some implementations, the decoder can have as many as 16or 32 pictures “in flight” in various stages of decoding, before outputof those pictures.

The timing and aggressiveness of PED depends on implementation. In somecases, a PED module when it executes tries to fill as many structuresfor pictures as possible, up to a limit set for the PED module. The PEDis blocked if the PED outputs are full or there is no input availablefor scanning.

Standards such as the H.264 standard may specify rules for the behaviorand state of the DPB, but typically do not detail how the DPB should bemanaged. In fact, the standards (and reference implementations) assumechanges to the DPB on a picture-by-picture basis, with updates occurringin serial order.

In some embodiments, the decoder (e.g., the PED module) plays a role inDPB management for multithreaded decoding. The decoder emulates a “live”DPB that behaves as in the simple, single threaded situation. Thedecoder simulates decoding of pictures, which would potentially updatethe DPB, by entering initialized (but as yet un-decoded) pictures intothe DPB. The decoder inputs commands in a picture command queue uses totrack completion of decoding tasks. A picture command in the queueassociates a condition (e.g., decoding of a particular picture) with anaction (e.g., output of a picture from the DPB, deletion of a picturefrom the DPB).

For example, the decoder populates the picture command queue during PED.The decoder puts one or more picture commands in a picture commandqueue. Each of the picture commands has an associated condition and anaction. For example, the associated condition is completion of decodingof a particular picture (whether successful or not), and the action isto output or delete a picture from the DPB. An output picture is apicture to be displayed. When a picture is deleted, tables, parameters,and other structures for the picture are removed from memory.

FIG. 6 shows an example FIFO picture command queue (600) that includespicture commands for the sequence of pictures having the display orderI₁, B₂, B₃, B₄, P₅, B₆, B₇, B₈, P₉ . . . and having the coded orderI_(I), B₂, B₃, B₄, P₅, B₆, P₉, B₇, B₈, in the bit stream. I, P and Bindicate I picture, P picture, and B picture, respectively, and thesubscript indicates display order. As the decoder scans the bit streamduring PED, the decoder adds picture commands starting at the head ofthe FIFO queue. According to the first command, when I_(I) is decoded itcan be output right away. When decoding completes for B₂, B₃ and B₄,there are no output commands or delete commands. The next commands putin the FIFO queue relate to the completion of decoding for P₅. Whendecoding of P₅ completes, the decoder can output and delete B₂, B₃ andB₄ from the DPB, and it can output P₅ from the DPB. The next commands inthe FIFO queue relate to the completion of decoding for P₉. Whendecoding of P₉ completes, the decoder can output and delete B₆ from theDPB.

Alternatively, the decoder uses a different data structure to trackpicture commands. For example, a node of the queue corresponds to acondition (e.g., completion of decoding of a particular picture) and thenode stores a single action to be performed upon satisfaction of thecondition (e.g., output one picture or delete one picture). With thisstructure, the queue (600) shown in FIG. 6 would have 10 nodes, one foreach action. A node for I_(I) would have one output action associatedwith it, and seven nodes for P₅ would have seven actions associated withthem, respectively. Or, the decoder uses queue nodes with other and/ordifferent fields.

C. Managing Picture Command Queue.

In some embodiments, the decoder uses a picture command queue to recordand execute picture commands in decoding order. The picture commandqueue facilitates complex DPB management in multithreaded decoding, withefficient use of memory and correct output of decoded pictures, eventhough decoding may occur in parallel and finish for pictures in anorder different than the coded bit stream order.

In conventional single threaded decoding, the decoder timing is totraverse the bit stream for a picture, decode the picture, then put thepicture in the DPB for output. When a decoded picture enters the DPB,depending on the parameters in the input picture, DPB managementroutines decide which picture(s) to output and which picture(s) todelete from the current DPB. The DPB is effectively a black box withinput and output only. When the decoded picture enters the DPB as input,the management routines can produce two types of commands: outputpicture(s) and delete picture(s).

For example, when the input decoded picture is an instantaneous datarefresh (“IDR”) picture, all the pictures in the current DPB are outputand deleted. Or, according to reference implementations of the H.264standard, when the MMCO parameter is equal to 5 for the input decodedpicture, all the pictures in the current DPB are output and deleted.Generally, if the decoder uses a “bumping” scheme for picture output,the not-yet-output picture with smallest value of PicOrderCnt( ) isoutput from the current DPB if the DPB is already full, and any alreadyoutput picture(s) marked as not used_for_reference are deleted from thecurrent DPB. The “output” and “delete” commands in the picture commandqueue for multithreaded decoding have similar meanings, but the commandsalso have conditions (e.g., decoding of particular pictures) associatedwith them.

In multithreaded decoding, pictures are not necessarily decoded in thecoded order they appear in the bit stream. Pictures later in coded ordermight actually be decoded first. Simply entering decoded pictures intothe DPB in the order of their actual decoding can cause problems whenthe pictures are not entered in coded order, for example, due toexecution of DPB commands like output and delete in the wrong order.

So, in some embodiments, a decoder simulates the behavior of a live DPBwith decoded pictures in it by entering initialized pictures in the DPB,where the initialized pictures are not necessarily decoded. The decoder(e.g., as part of PED) scans ahead in the bit stream, consideringcertain picture parameters for pictures but not sample data or sideinformation such as motion vector information or reference pictureidentifier information for the pictures. The decoder allocates memoryand creates data structures for a picture, perhaps populating thepicture with certain parameters, then enters the initialized pictureinto the DPB in its correct, coded order. Thus, the decoder findscomplete pictures, which are initialized with parameters but notdecoded, and enters them in the DPB. Typically, an initialized picturehas its picture header and slice header parameters correctly decodedfrom the bit stream as part of PED but sample data and side informationare not yet decoded.

The decoder can also record picture commands associated with the futurecompletion of decoding of an initialized picture. The decoder recordsthe commands, for example, in a FIFO queue such as the queue (600) shownin FIG. 6. The decoder executes the commands in the queue when theconditions (here, the completion of decoding for the initializedpictures) associated with the commands have been completed. The commandsthus execute in correct order (as set during PED) but the execution ofthe picture commands may be blocked at times to wait for decoding tocomplete.

FIG. 7 shows a generalized technique (700) for removing picture commandsfrom a picture command queue in multithreaded decoding. A decoder suchas the one described above with reference to FIG. 2 or other decoderperforms the technique (700).

The decoder decodes (710) a picture then checks (720) a queue forpicture commands that can be executed. The decoder determines (730)whether a command is ready (e.g., if the condition for the command atthe head of the queue has been satisfied) and, if so, removes (740) thecommand from the queue, executes (750) the command, andchecks/determines (720, 730) whether another command is ready.

FIG. 8 shows a diagram illustrating how picture command queue managementprocessing is embedded in different decoding tasks in an exampleimplementation. A working thread for a PED task (810) finds (812) acompleted picture, enters (814) an initialized version into the DPB, andrecords (816) the picture and one or more commands dependent on decodingof the picture in a FIFO queue. A command in the FIFO queue thus has adependent picture, which is the input picture to DPB associated with it.In this implementation, a dependent picture occupies one entry in thepicture command FIFO queue and has one or more actions associated withit (e.g., a set of output commands and a set of delete commands).

A working thread for the LF task (850) performs deblocking (852) as thelast part of decoding for a picture and determines (854) whether thereare any picture commands in the FIFO queue whose condition is completionof decoding for the just decoded picture. If so, the working thread forthe LF task (850) executes (856) the command(s). Thus, when a threadfinishes the decoding for a dependent picture, any commands associatedwith the dependent picture in the FIFO queue can be executed. Thecommands are executed in FIFO order. If decoding has not finished for aprevious dependent picture represented in the FIFO queue, the commandsfor a current dependent picture are not executed, even if decoding hasalready finished for the current dependent picture.

Commands are put in the FIFO queue in the order pictures have in the bitstream, regardless of the threading model. Although the command orderingis serial, decoding can be in parallel for multithreaded decoding. As aresult, picture command execution can be blocked at a particular pointin the FIFO queue, pending completion of decoding of a dependent pictureat that point.

In addition to recording output and delete commands associated with thecompletion of decoding for pictures, the command queue can store othertypes of commands. For example, in some implementations, the commandqueue also stores commands associated with changes in SPS or PPS. When aSPS or PPS changes, the associated action can be, for example, tablere-initialization for tables used in decoding, pool re-allocation formemory, or commands on a parameter set map/database. In general, thecommands are put in the FIFO queue in the serial order that the codedvideo bit stream provides for the commands. The decoder (e.g., PEDmodule) puts the commands in the FIFO queue without executing thecommands or waiting for completion of the conditions. The commands arelater executed, for example, during multithreaded decoding, when theconditions are satisfied.

D. Organizing and Scheduling Tasks.

In some embodiments, a decoder organizes tasks using a task dependencygraph and schedules execution of the tasks in multithreaded decoding.

1. Building Task Dependency Graphs.

To build the graph, the decoder analyzes dependencies between past andcurrent pictures. The decoder performs this analysis, for example,during PED. The decoder notes dependencies between stages of decodingfor the pictures. In general, a stage of decoding is a set of operationsor steps performed to decode a picture or part of a picture, forexample, PED, ED, MC, INTRA, LF or POST. In some implementations, thedecoder logs dependencies between segments, where a segment is a groupof macroblocks for part of a slice, for a slice, for parts of multipleslices, for multiple slices, or for a picture. Thus, picture-by-picturedependencies and slice-by-slice dependencies are special cases ofsegment-by-segment dependencies.

Within a picture, ED (including CABAC) is typically parallelizable fromslice to slice, which facilitates multithreaded decoding. A slice is notsplit into multiple segments for ED, but a segment may include multipleslices for ED. After ED, there may be inter-picture dependencies foroperations such as MC, which relies on previously decoded referencepictures. Typically, macroblocks can be segmented in arbitrary ways forMC stages. For LF, a segment typically includes one slice. Overall, thesegmentation decision for macroblocks in a picture can be the same fromstage-to-stage of decoding, or the segmentation decisions can vary fromstage-to-stage.

FIG. 9 shows a generalized technique (900) for creating a taskdependency graph for segments of macroblocks. A decoder such as the onedescribed above with reference to FIG. 2 or other decoder performs thetechnique (900).

The decoder identifies (910) dependencies for segments. For example, thedecoder identifies the dependencies for segments of a picture during alightweight scan through the coded video bit stream as part of PED.Alternatively, the decoder identifies dependencies using a differentscanning mechanism.

The decoder then organizes (920) the one or more segments, regardless ofslice boundaries. For example, within a picture, the decoder groupsintra-coded macroblocks together in a segment. In another picture, thedecoder groups motion-compensated macroblocks that use the samereference picture together as one segment, and the decoder groupsmotion-compensated macroblocks that use a different reference picturetogether as a second segment.

The decoder then assimilates (930) tasks for the segment(s) into a taskdependency graph. For example, the decoder builds a task dependencygraph such as the one shown in FIG. 10 for picture-by-picturedependencies. Or, the decoder builds a task dependency graph with tasksfor slices (or, more generally, segments) for nodes. In building thetask dependency graph, the decoder consider dependencies betweendifferent stages for the same segment (e.g., INTRA depends on ED, MCdepends on ED, LF depends on MC, LF depends on INTRA) and dependenciesbetween stages for different segments (e.g., INTRA for segment 2 maydepend on INTRA for segment 1 in the same picture, MC for segment 3 maydepend on LF for segment in another picture). Dependencies can beintra-picture dependencies or inter-picture dependencies.

The decoder determines (940) whether to continue with the next pictureand, if so, identifies dependencies for the next picture.

2. Example Task Dependency Graphs.

FIG. 10 shows an example task dependency graph (1000) for pictures 1, 2and 3. Picture 1 is an I picture, and picture 3 is a P picture withmacroblocks that use picture 1 as a reference picture. Picture 2 is a Bpicture with macroblocks that use picture 1 and picture 3 as referencepictures. The INTRA task for picture 1 depends on completion of the EDtask for picture 1, and the LF task for picture 1 depends on completionof the INTRA tasks for that picture. The MC task for picture 3 dependson completion of the LF task for (reference) picture 1 and the ED taskfor picture 3. The LF task for picture 3 depends on completion of the MCtask for the picture. For picture 2, the MC task depends on completionof three other tasks—the ED task for picture 2 and the LF tasks forpictures 1 and 3. The LF task for picture 3 depends on completion of theMC task for picture 3. Alternatively, the graph (1000) also includes aMV setup task for picture 2, which depends on completion of the MC taskfor picture 3, and upon which the MC task for picture 2 is dependent.

In some implementations, graph nodes represent segments. If a picturehas 8000 macroblocks, the macroblocks might be organized as foursegments for parallelization in multithreaded decoding. If decoding issplit into 6 stages (e.g., PED, ED, INTRA, MC, LF and POST) and thereare 15-20 pictures in flight at various stages of decoding, the taskdependency graph can easily include hundreds of nodes, which facilitatesfine-grained scheduling of multithreaded decoding.

In some implementations, the task dependency graph is organized as a setof nodes. A node structure has a counter that indicates how many taskdependencies the node's task has. The counter is incremented (ordecremented) when a task dependency is added (or completed/removed). Forexample, a node structure for the MC for Picture 2 task of FIG. 10 wouldhave a counter=3, then the counter would be decremented as the LF forpicture 1, ED for picture 2 and LF for picture 3 tasks complete. A nodestructure also has an expandable list of its dependencies. For example,the node structure for the MC for Picture 2 task of FIG. 10 has onedependency in its list—LF for picture 2. Dependencies are added to thelist when noted during PED. When a task completes, the task(s) dependenton the completion are notified, with counter(s) for those task(s) beingdecremented. For example, when the MC for Picture 2 task of FIG. 10completes, the counter for the node structure for the LF for picture 2task is decremented. When the dependency counter is zero for a taskduring decoding, the task is put in the ready task list for scheduling.Alternatively, the node structure for tasks in the task dependency graphincludes other and/or additional fields.

3. Scheduling Tasks.

The decoder then schedules tasks for decoding using the task dependencygraph. In implementations in which the graph nodes include dependencycounters, the decoder adds a task to a list of ready tasks when thedependency counter for the task reaches zero. During multithreadeddecoding, the decoder selects tasks from the ready list according to oneor more heuristic approaches. For example, the heuristic approach is:

(a) FIFO—tasks are scheduled in the order they were put in the readylist;

(b) stage priority—tasks are scheduled depending on priority for theirdecoding stage;

(c) picture age—tasks for oldest pictures have highest priority;

(d) number of dependencies on tasks—task with most dependencies on itexecutes first, such that completion of the task potentially unblocksmore other tasks in the graph; or

(e) shortest critical path from task to output—tasks that put picturesclose to output are executed first.

Alternatively, the task scheduler considers other and/or additionalheuristics.

E. Recovery Mechanisms.

In some embodiments, a decoder includes special mechanisms for handlingdecoding of a corrupted bit stream or starting decoding from anarbitrary location in a bit stream. For example, according to onerecovery mechanism, the decoder during PED finds a valid picture tostart decoding after corruption of part of an encoded video bit streamor to start decoding from an arbitrary location indicated in the encodedvideo bit stream. According to another recovery mechanism, the decoderduring PED handles corrupted parameters in a slice header and attemptsto recover. According to another recovery mechanism, the decoder handleserrors in other decoding stages (e.g., ED, MC, INTRA, LF). Themechanisms can be used in combination or separately. Collectively, themechanisms improve the robustness of decoding for bit streams that havea high probability of becoming corrupted.

An IDR picture is a valid starting point for decoding—the pictures afteran IDR picture do not reference pictures before the IDR picture formotion compensation. An IDR picture typically begins a video sequence,but IDR pictures may be rare after that. For some applications, IDRpictures appear only once per chapter of video or only once every 30seconds in a sequence. When trying to start decoding from an arbitrarylocation in the bit stream, there might not be an IDR picture forseveral seconds or even minutes. As a result, while waiting for an IDRpicture, downloaded bits may be wasted or reasonable quality picturesmay be skipped.

Therefore, in some embodiments, as part of a recovery mechanism, adecoder (e.g., a PED module) seeks an I picture at which to startdecoding, as if the I picture were an IDR picture. An I picture is intracoded; it includes I slices but not P slices or B slices.

FIG. 11 shows a technique (1100) for finding a valid picture to begindecoding at an arbitrary location in an encoded video bit stream. Adecoder such as the one described above with reference to FIG. 2 orother decoder performs the technique (1100). The decoder performs themethod, for example, after detecting corruption in the bit stream orafter receiving an indication that it should start decoding from aparticular, arbitrary location in the bit stream.

To start, the decoder finds (1110) a picture in the encoded video bitstream. For example, a PED module of the decoder parses a NALU from thebit stream, where the NALU is for a complete picture, then initializesstructures for parameters and data for the picture. Alternatively, thedecoder finds the picture using another mechanism.

The decoder determines (1120) whether the picture is an I picture. Ifnot, the decoder cleans up (1130) the picture. For example, the decoderremoves any picture commands put in a picture command queue for thepicture and releases memory used for structures for the picture.

If the picture is an I picture, the decoder schedules (1140) decodingfor the picture. For example, the decoder puts an initialized picture inthe DPB, puts picture commands for the picture in a picture commandqueue, and assimilates one or more tasks for the picture into a taskdependency graph for multithreaded decoding.

The decoder continues the technique (1100) until it finds a valid Ipicture or IDR picture in the bit stream. In some implementations, aflag bFirstTimeSeek indicates whether the decoder should perform thetechnique (1100). At the start of decoding or when recovering from anerror, bFirstTimeSeek is TRUE. When the flag is TRUE, a PED module inthe decoder finds a complete picture and checks whether the picture isan I picture. If the picture is an I picture, the PED module sets theflag bFirstTimeSeek to be FALSE and decoding starts from the I picture.Otherwise, the PED module continues trying to find an I picture.

Even after an I picture is found, there may be errors in decodingstarting from the I picture. For example, macroblocks of later Bpictures (in coded order) may reference pictures from before the Ipicture. Or, macroblocks of a later P picture may reference (by remoteprediction) pictures that are currently unavailable. Or, there may beparts of the bit stream that are corrupted after the I picture. Some ofthe errors may be ignored or concealed (e.g., errors in frame_num gap,reference pictures being unavailable). Other errors can require that apicture (or part thereof) be treated as corrupted, however.

In some implementations, a decoder handles errors differently dependingon whether they are identified during a PED stage or during anotherdecoding stage. When the decoder catches the error during a PED stage,the decoding processes the error by cleaning up the picture in question(and skipping decoding of the picture) or just skipping decoding of thepicture, depending on the type of error. If the error occurs duringanother stage, the decoder processes the error using another errorhandling mechanism such as skipping decoding of the affected part (e.g.,slice) but decoding other parts, or concealing the error in the affectedpart.

FIG. 12 shows a technique (1200) for handling errors identified duringPED processing. A decoder such as the one described above with referenceto FIG. 2 or other decoder performs the technique (1200). The decoderhandles different kinds of PED errors differently. In the technique(1200), the handling of the error depends on several factors, includingwhether the error is fatal and whether the picture can be entered into aDPB.

The decoder catches (1210) an error and determines (1220) whether or notthe error is fatal. If the PED error is a fatal, error (e.g., an “out ofmemory” error), the decoder cleans up (1230) the corrupted picture. Forexample, the decoder cleans up any commands in a picture command FIFOqueue that are dependent on the corrupted picture, and the decoderreleases memory for the structures for the picture back to a memorypool. The decoder also closes since the error was fatal.

If the PED error is not fatal, the decoder determines (1240) whether thecurrent picture can successfully be entered into the DPB as aninitialized picture. Some types of errors in slice headers cause errorsin DPB management routines, preventing successful handling of thepicture in the DPB. Other types of slice header errors do not interferewith DPB processing, however.

If the initialized picture successfully enters the DPB, the decoderenters the picture in the DPB but marks (1250) the picture as skipped.In some implementations, the decoder marks the corrupted picture asskipped by setting a flag bSkipDecodingPicture=TRUE. The decoder leavesthe corrupted picture inside the DPB, but decoding of it is skipped andit is processed like a skipped picture. For example, the decoder causesdisplay of a picture at the correct time for the corrupted picture byrepeating the display of another picture. Alternatively, the decoderhandles skipped pictures in another way.

If the initialized picture does not successfully enter the DPB, thedecoder cleans up (1230) the corrupted picture. For example, the decodercleans up any commands in a picture command FIFO queue that aredependent on the corrupted picture, and the decoder releases memory forthe structures for the picture back to a memory pool. Sometimes, the PEDmodule finds an error in slice header parameters that prevents DPBprocessing, so the whole picture is treated as corrupted and not enteredin the DPB, even if other slices in the picture are decodable.

After the decoder processes a non-fatal PED error, the decoder continuesby processing the next picture in coded order. The decoder continuesuntil it finds a valid, error-free picture, reaches the end of theencoded video bit stream, or encounters a fatal error.

When the decoder encounters an error during a non-PED task (e.g., ED,MC, INTRA, or LF), the decoder marks the slice including the error ascorrupted and performs error handling for it. For example, the decodersimply skips decoding of the slice but decodes other slices in thepicture. Or, the decoder skips decoding of the slice and attempts toconceal the error using other decoded content. If the picture is decodedwith a GPU that operates on whole pictures, however, the pictureincluding the corrupted slice is skipped.

V. Innovations in Neighbor Determination.

In some embodiments, a decoder uses table-based mechanisms to determinethe availability of neighboring macroblocks, blocks, and sub-blocksduring decoding. The table-based neighbor availability determinationsdescribed herein, especially when used with state machine transitions,are both memory efficient and fast.

For many standards, decoding an encoded video bitstream usesavailability and location information about neighboring macroblocks,sub-macroblocks, blocks and sub-blocks. Neighbor availability decisionsaffect numerous decoding operations. For example, in H.264 decoding, thedecoder considers neighbor context in setting up context for entropydecoding with CABAC, entropy decoding with CAVLC, spatial intraprediction, and mode computation for intra prediction. Neighboravailability determinations may also be made as part of in-loop deblockfiltering, motion vector prediction, and other operations.

Despite the prevalence of the operations, the H.264 standard specifiescomplex logic for determining available neighbors and neighborpositions. The logic is relatively slow, often resulting in inefficientmemory switching. The reference software also provides unsatisfactoryperformance for neighbor availability and position determinations.

In contrast, table-based neighbor determination mechanisms describedherein are efficient and fast. A decoder reuses tables that arepre-computed or computed a small number of times during a decodingsession. The tables typically have a small memory footprint, and thetable lookup operations are relatively fast.

A. Techniques for Table-based Neighbor Availability Determination.

This section presents techniques for using table-based neighboravailability determinations during decoding. A decoder such as the onedescribed with reference to FIG. 2 or other decoder performs one or moreof the techniques.

FIG. 13 shows a generalized technique (1300) for using one or moretables to determine neighbor availability during decoding. To start, thedecoder gets (1310) one or more tables indicating availabilityrelationships between macroblocks, sub-macroblocks, blocks and/orsub-blocks. For example, the decoder gets tables as described in theexample implementations section. Alternatively, the decoder gets tableshaving a different organization and/or storing different types ofinformation.

In hierarchical approaches, the decoder gets tables that drill down frommacroblock neighbor availability information to sub-macroblock neighboravailability information. For example, for a progressive picture orfield picture, the decoder gets a first availability table indicatingdifferent macroblock (or macroblock pair) neighbor patterns and gets asecond availability table indicating different sub-macroblock (e.g.,block, sub-block) neighbor patterns. Certain tables can bepre-determined for certain configurations of video. Or, where the sametable is reused throughout decoding, the decoder can compute the tablesduring initialization for a decoding session.

The decoder then uses (1320) the one or more tables to determineneighbor availability during decoding. For example, the decoder uses thetables as described in the example implementations section.Alternatively, the decoder uses the tables in different ways.

The way the decoder uses the tables can depend on whether the picturebeing decoded is a progressive picture, field picture, or MBAFF picture(generally, an interlaced frame with field/frame coding decisions withinthe frame). For example, for a progressive picture or field (non-MBAFF)picture in some embodiments, the decoder uses a first table to determinemacroblock neighbor availability. For a MBAFF picture, the decoder usesa first table to determine macroblock pair neighbor availability. Thedecoder then determines sub-macroblock neighbor availability using asecond table.

When the decoder sets up a state machine, the decoder can use the statemachine to quickly determine macroblock (or macroblock pair)information. FIG. 14 shows a generalized technique (1400) for using astate machine and one or more tables to determine neighbor availabilityduring decoding of a progressive or field picture.

To start, the decoder gets (1410) two tables indicating availabilityrelationships between macroblocks, sub-macroblocks, blocks and/orsub-blocks. For a particular slice in the picture, the decoder also sets(1420) up a state machine for the multiple macroblocks in the slice. Adecoding task creates the state machine and uses the state machine forvarious decoding operations for the slice. For a given state, the statemachine stores information indicating number of consecutive macroblocksin the state and an index to a first availability table indicatingavailability information for the state. Or, instead of storing indicesfor the respective states, the state machine directly stores macroblockavailability information on a macroblock-by macroblock-basis, forexample, as a bit field with four bits per macroblock, one bit for eachpossible neighbor macroblock. Alternatively, the decoder sets up a statemachine on a picture-by-picture or some other basis.

A first availability table associates different states with differentmacroblock neighbor availability patterns. The decoder determines (1430)macroblock neighbor availability using the state machine and the firstavailability table (e.g., by lookup or writing values into the statemachine). The decoder then determines (1440) sub-macroblock (e.g., 16×8,8×16, 8×8, 4×8, 8×4, or 4×4 sizes) neighbor availability using themacroblock neighbor availability and a second availability table. Thesecond availability table associates different macroblock neighboravailability patterns with different block/sub-block neighboravailability patterns. The decoder then decides (1450) whether tocontinue with the next slice (if any) in the picture or finish.

Or, for a MBAFF picture, the decoder sets up a state machine formultiple macroblocks in a slice. A decoding task creates the statemachine and uses the state machine for various decoding operations forthe slice. For a given state, the state machine stores informationindicating number of consecutive macroblock pairs in the state and anindex to a first availability table indicating macroblock pair neighboravailability information for the state. Or, instead of storing indicesfor the respective states, the state machine directly stores macroblockpair neighbor availability information on a macroblock pair-by-pairbasis. The first availability table associates different states withdifferent macroblock pair neighbor availability patterns. The decoderalso sets up a neighbor context vector for each of the respectivemacroblocks of the pairs. The neighbor context vector indicates, forexample, field or frame mode for a current macroblock, field or framemode for each of plural neighbor macroblocks, and whether the currentmacroblock is a top or bottom macroblock in its macroblock pair. Thedecoder determines macroblock pair neighbor availability using the statemachine and the first availability table. The decoder then determinessub-macroblock neighbor availability using the macroblock pair neighboravailability and a second availability table. The second availabilitytable associates different macroblock pair neighbor availabilitypatterns with different block/sub-block neighbor availability patterns.

Aside from computing neighbor availability information, the decoder alsodetermines and stores neighbor locations for use in various decodingoperations. In some implementations, the neighbor locations are storedas offsets relative to the current macroblock.

B. Example Implementations for Table-based Neighbor Determination.

In some implementations, a decoder computes availability and locationinformation via a hierarchical approach using a state machine and tablesas described in this section.

In general, the decoder uses a state-machine to provide neighboring MBavailability information (in a non-MBAFF picture) or neighboring MB-pairavailability information (in a MBAFF picture). The decoder uses theavailability information to index tables that provide availabilityinformation for MB, sub-MB, block, and/or sub-block levels. Duringdecoding, the decoder deduces the availability of neighboring samplelocations from the availability of neighboring partitions that containthose sample locations. The decoder uses additional tables to recordoffsets from the current MB/sub-MB/sub-block to neighboringMB/sub-MB/sub-block. The details of the table-based neighbordetermination vary depending on whether the content being decoded ispart of a MBAFF picture or non-MBAFF picture.

1. Determining Neighbor Availability for Non-MBAFF Pictures.

For a progressive picture or field picture, a decoder uses a statemachine for MB-level neighbor availability determinations. The decodersets up the state machine for each slice before entropy decoding. Thestate machine accounts for picture boundaries and slice boundaries, andit provides the “state” of availability of neighboring MBs (in theabsence of flexible macroblock ordering). FIG. 15 shows a chart (1500)indicating MB neighbors to the left of a current MB, above the currentMB, above and to the right of the current MB, and above and to the leftof the current MB. For the sake of convention, these are labeled A, B, Cand D, respectively.

The decoder uses two different state-machines, depending on whether thefirst MB in the slice is at the left edge of the picture. FIG. 16 showsmacroblocks for an example state-machine (1600). For the state machine(1600), the current slice (shaded region) begins in the middle of thepicture. (A simpler state machine can be used when the MB beginning theslice is at the left edge of the picture, omitting certain categories ofstates.) For a given state, the state machine stores the followinginformation: (1) how long to stay in the current state (the number ofconsecutive MBs in raster order that share this state), (2) an indexinto an availability table that gives the availability information forthis state (e.g., the table shown immediately below), and (3) the nextstate. For example, at the beginning of the slice, the state machine(1600) starts at state a, which has a length of one MB. For the rest ofthe MBs in the row, the state machine moves to state b. The nextmacroblock row begins with state c, and so on. The following table showsMB neighbor availability information (using labels A, B, C and D shownin FIG. 15) associated with the different states in the state machine.

State Available Neighbors a None b, d A (may be skipped) c None; or C(e.g., if first MB in slice is above right) e A, C (may be skipped) f A,B (e.g., if last MB in second row); or A, B, C g, j A, B, C, D h, k A,B, D i B, C

For instance, state a corresponds to the case where none of the MBneighbors is available. In state b (which may be skipped if the first MBin the slice is the last MB in the row), the left neighbor is alwaysavailable. Some states may be assigned different MB availabilitydepending on the MB location. State c, for example, either has noavailable neighbors or has an available above-right neighbor (if themacroblock starting the slice is one MB position away in the horizontaldirection). States i, j and k are repeated starting from the fourth rowof MBs in the slice. The MB neighbor availability information for aparticular state can be represented with 4 bits, one each for A, B, Cand D, where the 0/1 values indicates whether the neighbor MB is or isnot available.

The decoder uses the MB neighbor availability information formacroblocks to determine the sub-MB/sub-block neighbor availabilityusing table lookups. Within a 16×16 MB, there may be partitions used atvarious stages of decoding, where the partitions have different sizesand appear at certain allowed locations. For example, in the H.264standard, allowed sizes include 16×16 MB, 16×8 blocks at any of 2defined locations in a MB, 8×16 blocks at any of 2 defined locations ina MB, 8×8 blocks at any of 4 defined locations in a MB, 8×4 blocks atany of 8 defined locations in a MB, 4×8 blocks at any of 8 definedlocations in a MB, and 4×4 blocks at any of 16 defined locations in aMB. This yields 1+2+2+4+8+8+16=41 partition/location combinations.

A table maps the MB neighbor availability information to thesub-MB/sub-block neighbor availability information. For example, for aparticular partition (e.g., 8×4 block at given location), the decodermaps the MB neighbor availability pattern to a sub-MB/sub-block neighboravailability pattern. Where there are four possible MB neighbors A, B, Cand D, there are 2⁴=16 combinations and MB neighbor availabilitypatterns. For the particular partition/location combination, where thereare four possible partition neighbors A, B, C and D, the decoderdetermines which of 16 partition neighbor availability patterns applies.

As an example, a 4×4 block in the top row of a MB will not have anavailable 4×4 neighbor above it if the MB above the 4×4 block's MB isnot available. On the other hand, a 4×4 block on the second row of theMB will have a 4×4 neighbor above (within the same MB). MBs, sub-MBs,and sub-blocks that occur later in decoding order are also considered tobe unavailable. This includes MBs, sub-MBs, and sub-blocks that belongto MBs with bigger MB addresses compared to the current MB, as well asMBs, sub-MBs, and sub-blocks that occur later in the scan during thedecoding of the current MB, where the scan order of partitions within aMB or block is generally left to right, top to bottom.

FIG. 17 shows a pseudocode listing (1700) for a data structureimplementing a sub-MB availability table. The decoder creates the table,for example, at the start of a decoding session and reuses the tablethroughout decoding of a sequence having pictures with a particular MBwidth. For each of 41 possible partition/location combinationsrepresented in the array rgBlockAvailable[ ], there is an array uiAvail[] with 16 elements. For a given partition/location combination, thedecoder uses a 4-bit value indicating MB neighbor availability (1 bitfor each of A, B, C and D neighbor MBs) as an index to the arrayuiAvail[ ]. The corresponding entry indicates the partition neighboravailability for the given partition/location combination, consideringthe MB neighbor availability. The corresponding entry can be, forexample, a 4-bit value indicating whether A, B, C and D partitionneighbors are available or not. For example, for a 16×8 partition at thebottom of the current macroblock, the entry indicates whether left,above, above-left and above-right neighbors are available. The above16×8 neighbor is available, as it is in the same MB, and the above-right16×8 neighbor is not available, as its MB is later in scan order.

The decoder also stores the locations of neighboring MBs for somesub-MBs and sub-blocks. The decoder stores the location information inthe form of offsets from the current MB. The location of neighboring MBsis used during constrained intra prediction. In the progressive picturecase, the locations of neighboring 4×4/8×8 blocks and sample locationsmay be directly computed, considering MB neighbor availabilitypossibilities and whether positions are in the current MB. FIG. 18 showsa pseudocode listing (1800) for example data structures used to storeneighboring MB information for 8×8 blocks and 4×4 sub-blocks.

2. Determining Neighbor Availability for MBAFF Pictures.

For an MBAFF picture, the decoder uses different tables and/oroperations. The decoder sets up a state machine used to determine MBpair level neighbor availability. In a MBAFF frame, MB addresses(MBAddr) are ordered such that MBAddr/2 goes through MB pairs in rasterscan order. Also, MBs within a MB pair are both available or both notavailable. The decoder uses a state machine analogous to the one usedfor non-MBAFF pictures, but the output is interpreted as MB pairneighbor availability instead of MB neighbor availability. The decodersimilarly uses a table mapping states to MB pair neighbor availability(instead of MB neighbor availability).

The decoder also sets up a neighbor context bit vector for each MB. Thevector indicates whether a given, current MB is encoded in field orframe mode. For each of the four neighbor MB pairs A, B, C and D, thevector also indicates whether the MB pair is encoded in field or framemode. Finally, the vector indicates whether the current MB is the top MBor bottom MB of its MB pair. FIG. 19 shows an example neighbor contextbit vector (1900) for an MB of an MBAFF picture.

The decoder uses MB pair neighbor information and current MB statusinformation (from the bit vector for the current MB) to determine sub-MBpartition information using a table. The table maps different MB pairneighbor/current MB patterns to different partition neighbor patterns.Within a 16×16 MB, the possible partitions and locations are typicallythe same as for non-MBAFF pictures (e.g., 41 combinations for H.264).Where there are four possible MB pair neighbors A, B, C and D, there are2⁴=16 combinations and MB pair neighbor patterns. For each, there are 4combinations for field/frame coding mode and top/bottom status for thecurrent MB. This yields 64 possible combinations for MB neighboravailability for indices to the table. For a particularpartition/location combination, where there are four possible partitionneighbors A, B, C and D, the decoder determines which of 16 partitionneighbor availability patterns applies.

An example data structure implementing a sub-MB neighbor availabilitytable for MBAFF pictures is the two-dimensional array:

unsigned char rgrgbBlockAvailableMBAFF[16*4][41].

The decoder computes the values of the table, for example, duringinitialization for a decoding session for a sequence. The seconddimension is indexed by the 41 partition/location combinations as in thenon-MBAFF case, and the first dimension is indexed by a value from 0 to63 given by:

4×MBPairAvail+NeighborContextVector & 0×03,

where MBPairAvail is a 4-bit value indicating the MB-pair neighboravailability (1 bit for each of A, B, C and D) from the state machine,and NeighborContextVector & 0×03 implements a bit mask on a neighborcontext bit vector to give the field/frame coding mode and top/bottomstatus for the current MB. The MB neighbor availability depends on thefield/frame and top/bottom information for the current MB. Thefield/frame coding mode information for neighbor MB pairs is notconsidered when all pixels in a neighboring MB pair are either availableor not available, regardless of whether the MB pair is field or framecoded.

The decoder stores location information for neighbor MBs for some sub-MBand sub-blocks. In an MBAFF frame, it is not as straightforward tocompute the locations of the neighboring MBs, sub-MBs, and sub-blocks.Determining the location information is complicated by the possibilityof different field/frame coding mode decisions for neighbor MB pairs.

FIG. 20 shows pseudocode (2000) for example data structures for storinglocation information for an MB, its 8×8 blocks, and its 4×4 sub-blocks.The location information is stored in a two-dimensional array, where thefirst dimension is indexed by the 6-bit value of a neighbor context bitvector and the second dimension is indexed by the partition and locationcombination (1 16×16 possibility, 4 8×8 possibilities, 16 4×4possibilities).

In each vector/partition/location position of the array, MB neighborlocations and (if appropriate) 4×4 sub-block (or 8×8 block) neighborlocations are stored. The MB locations are stored as offsets from thecurrent MB address. 4×4 sub-block neighbor locations store the verticaloffsets in 4×4 sub-block units from the top-left 4×4 sub-block of thecurrent MB. 8×8 block neighbor locations can also be stored as offsetsfrom the top-left of the current MB. The horizontal offsets can bedirectly computed when needed as in the non-MBAFF case.

In intra prediction, the sample locations within each 4×4 or 8×8 blockcan have left neighbors belonging to two different MBs depending onwhether the locations belong to the top or bottom field of the picture.This fact is especially important for constrained intra prediction whereone of the neighboring MBs may be intra coded whereas the other is intercoded. Therefore, two offsets are stored for the left MB neighbors, forexample, by packing two different offset values into the variablebMbOffsetLeft.

Furthermore, in intra prediction, table lookup of neighboring samplelocations can be completely avoided via the following deductions. Theleft neighbor (if available) is the sample location immediately to theleft of the current sample location in the picture. If the current MB isframe coded, the neighbor above (if available) is the sample locationimmediately above the current sample location in the picture. Otherwise(if the current MB is field coded), the neighbor above (if available) isthe sample location immediately above the current sample location in thesame field of the picture. The above-right and above-left neighbors (ifavailable) can be derived in a similar manner.

VI. CABAC Decoding Innovations.

In some embodiments, when a decoder decodes CABAC-encoded videoinformation, the decoder uses one or more innovations that improve theefficiency of the CABAC decoding. Many of the CABAC decoding innovationscan be used in combination.

CABAC has remarkable compression properties but, in standardimplementations, is computationally complex. CABAC encoding and decodingare notoriously slow and resistant to optimization for conventionalarchitectures. These performance problems have several causes. First,the core CABAC decoding routine serially processes one bit at a time offof a bit stream, and decoding of some syntax elements does not advancethe stream pointer at all. Second, in standard implementations, thedecoder performs heavy processing for each bit, which typically involvesmultiple conditional branches and context switching. Third, in standardimplementations, the decoder inefficiently calls the core decodingfunction (which is labeled biari_decode_symbol in many implementations).For example, in many decoding functions that compute syntax elements,calls to biari_decode_symbol are embedded in extensive conditionalbranches that are negotiated in order to select the appropriatesituation. This organizational scheme leads to code that is notlocalized well. Based on what is happening at any given moment, theroutines may jump all over, which results in incorrect loading of codeinto the instruction cache and leads to other inefficiencies. Inpractice, naïve implementations of CABAC decoding can slow down decodingto the extent that 10 frame per second video is displayed at less than 1frame per second.

FIG. 21 shows a pseudocode listing for the core decoding functionbiari_decode_symbol from a reference implementation of CABAC decodingaccording to the H.264 standard. Generally, the stages of the algorithmare (1) initialize variables, (2) compare value to range and takeappropriate action(s) based on results of the comparison (e.g., changingstate, changing value, changing range), and (3) renormalize range. Thedecoding function decodes exactly one bit of information from n bits ofdata off of the stream, where n is often zero. Typically, the bit ofinformation is the most probable symbol (“MPS”). Constraints on systemmemory hinder efforts to decode several bits at a time. Without feasibleparallel processing opportunities, the goals become shortening the basicsteps and reducing the performance impact of conditional logic.

Many of the CABAC decoding innovations described in this section arearchitecture independent, stemming from recurrent inefficiencies in thecore decoding function. Other innovations are architecture dependent andwork for an architecture such as the x86 architecture or a gamingconsole architecture. Different architectures have differentcharacteristics and, correspondingly, different innovations are adaptedfor different architectures.

A. Higher Volume Loading of Stream Bits.

In the pseudocode decoding function (2100) shown in FIG. 21, during there-normalization of the range variable, bits are read from the bitstream as needed. The value variable is updated on a single bit-by-bitbasis (indicated by the value:=updatevalue operation) from a variableDBuffer that holds 8 bits of data. The variable Dbits_to_go keeps trackof how many of the bits of the DBuffer byte have been transferred intothe value variable. The bit stream is considered an array of bytes, andwhen the DBuffer byte is used up, the decoder loads another byte fromthe bit stream (indicated by the get_a_byte function). This loadingmechanism is inefficient in several respects. Loading bits from the bitstream on a byte-by-byte basis is inefficient. Moreover, loading asingle byte is inefficient in many architectures, requiring mask, shiftand load operations to get the single byte.

According to a first aspect of the CABAC decoding innovations, when adecoder performs context-adaptive binary arithmetic decoding, thedecoder, as necessary, loads encoded video information from a bit streamon a machine word-by-machine word basis. The machine word is, forexample, 32 bits or 64 bits. By loading bits on a machine word-by-wordbasis, the decoder makes fewer calls to the get_a_byte function. If theword size is 32 (or 64), the decoder makes ¼ (or ⅛) as many calls to theget_a_byte function. Moreover, in many architectures, loading an entiremachine word is more efficient than loading a single byte, whichrequires additional operations.

In some implementations, the variable dBuffer holds the entire machineword. Updates are performed a word at a time.

B. Arithmetic with Left-adjusted Integers.

In the reference pseudocode listing (2100) shown in FIG. 21, threevariables value, DBuffer, and DBits_to_go are intimately involved inkeeping the value being decoded updated with bits off of the bit stream,as needed. To update the value (indicated by the value:=updatevalueoperation), the decoder performs a combination of instructions. Thedecoder shifts the value variable, then performs mask, shift, load andor instructions in order to load each new bit from the stream fromDbuffer into the value variable. Theoretically, the value is a 9 bitwindow on the bit stream, with DBuffer holding the next bits to beloaded into value.

According to another aspect of the CABAC decoding innovations, when adecoder performs context-adaptive binary arithmetic decoding, thedecoder stores the value being decoded along with available stream bitstogether in a single variable. In a second variable, the decoder storesbit count information about the first variable. The decoder then usesthe first and second variables in the context-adaptive binary arithmeticdecoding.

In some implementations, the decoder shifts the 9 bits for value to theleft of a single variable (e.g., 32-bit word) and puts available streambits in the other bits of the variable. The decoder performs arithmeticwith the left-adjusted integer for the value being decoded, keepingfuture bits to be decoded on the right side of the same term. This savessingle-bit loading, shifting and masking instructions that existed inthe original implementations of the reference pseudocode (2100). Thevalue being decoded can be kept as the top x bits in a word (e.g., top 9bits), with the rest of the word available for storing stream bits asthey would otherwise be stored in DBuffer or the bit stream. For a32-bit word (or 64-bit word), this leaves 23 (or 55) bit positionsavailable.

For example, the decoder loads a word into the single variable directlyfrom the bit stream. The top 9 bits are the value being decoded. Whenthe value is updated, the single variable is bit shifted such that oneor more bits of the value decoded are shifted out, and one or moreavailable stream bits—previously to the right of the top 9 bits—in thesingle variable are shifted into the value being decoded. The decoderthus avoids time-consuming mask, shift and load instructions for bitwiseupdates to the value being decoded. Once every half-word of data (or atsome other interval), the decoder reloads bits off of the bit streaminto the single variable (e.g., into the lower half-word of bits in thesingle variable). The decoder thus uses two variables, which can belabeled value (the single variable for the value being decoded and someavailable stream bits) and Dbits_to_go (which tracks when there are nolonger 9 stream bits available at the left part of the single variable).Compared to the reference pseudocode (2100), the variable DBuffer is notneeded, which is an added efficiency gain.

C. Lookup Tables for Shift Amount.

In the reference pseudocode listing (2100) shown in FIG. 21, a loop inthe re-normalization stage includes conditional execution branches.Specifically, in a while loop the decoder checks a condition andleft-shifts value and range one bit at a time. The value being decodedis also updated with new bits from the stream, one bit at a time, asneeded. The point of the loop is to left-shift both value and range sothat the top bit of range is a 1, and so that Value contains the current9 bits off the stream that are being decoded.

According to another aspect of the CABAC decoding innovations, duringrenormalization in context-adaptive binary arithmetic decoding, adecoder determines a multiplication amount (e.g., based on a lookup ofrange in a table) and multiplies range by the multiplication amount(e.g., left shifting range by a left shift amount corresponding to themultiplication amount). The decoder can then also multiply value by themultiplication amount (e.g., by left shifting). This can eliminateperformance penalty of the while loop and conditional execution branchesin the renormalization, instead providing a simple, fast, and smallfootprint mechanism for renormalization.

In some architectures, multiplications are costly operations and shiftsare not, so the decoder looks up shift amounts and performs left shifts.In other architectures, integer multiplications are not costly, and thedecoder looks up multiplication amounts.

FIG. 22a shows a technique (2200) for performing context-adaptive binaryarithmetic decoding with a range lookup table for dynamic shift amounts.A decoder such as the one described above with reference to FIG. 2 orother decoder performs the technique (2200).

To start, the decoder initializes (2210) variables for thecontext-adaptive binary arithmetic decoding, for example, initializingvariables as shown in the reference pseudocode listing (2100) of FIG.21. The decoder then compares (2220) value and range and takes anappropriate action, for example, setting a state variable and (ifappropriate) adjusting range and value as shown in the referencepseudocode listing (2100) of FIG. 21. Then, the decoder (if appropriate)renormalizes (2230) range and adjusts value, using a lookup table thatmaps different values of range to different shift amounts. The decoderlooks up the current range in the table and finds an appropriate dynamicshift amount. The decoder can then shift range and value by the shiftamount. The following table shows an example range lookup table.

Range Dynamic Shift Amount 1 8 2 7 3 7 4 6 . . . 7 6 8 5 . . . 15 5 16 4. . . 31 4 32 3 . . . 63 3 64 2 . . . 127 2 128 1 . . . 255 1 256 0 . .. 511 0

Thus, the decoder uses the lookup table (instead of the while loop) andrange to determine a dynamic shift amount. The table lookup is fast (nobranches) and precise. Moreover, the number of shift operations per callto the core decoding function is reduced to one. The decoder performsone dynamic shift operation of x bits instead of x single-bit shiftoperations.

In alternative embodiments, the decoder uses multiple lookup tables. Forexample, the decoder uses a first lookup table for the first n bits(e.g., first 5 bits) of range, which addresses the most common cases forrange. The smaller lookup table results in faster lookup operations mostof the time. If the range is not in the first lookup table, the decoderuses a second lookup table for the remaining bits of range. Or, thedecoder uses more lookup tables.

D. Unrolled Loop Logic.

A range lookup table provides satisfactory performance when dynamicshifts are inexpensive instructions. In some architectures, however,dynamic shifts have a high computational cost.

According to another aspect of the CABAC decoding innovations, a decoderuses unrolled loop logic when determining a shift amount forrenormalization. In some implementations, the decoder uses a mixedapproach with unrolled loop logic and, in place of some decisionbranches, a range lookup table. For example, during renormalization incontext-adaptive binary arithmetic decoding, a decoder determines amultiplication amount (e.g., shift amount) using unrolled loop logic(and potentially also using a range lookup table). The decoder thenmultiplies range by the multiplication amount (e.g., by left shiftingrange). In some implementations, the decoder traverses the unrolled looplogic, checking common cases for range which have associated with themfixed shift amounts for fixed shift operations. If range is not one ofthe common cases, the decoder looks up range in the lookup table todetermine a dynamic shift amount.

FIG. 22b shows a technique (2201) for performing context-adaptive binaryarithmetic decoding with unrolled loop logic (and potentially a rangelookup table) for shift amounts. A decoder such as the one describedabove with reference to FIG. 2 or other decoder performs the technique(2201).

To start, the decoder initializes (2210) variables for thecontext-adaptive binary arithmetic decoding, for example, initializingvariables as shown in the reference pseudocode listing (2100) of FIG.21. The decoder then compares (2220) value and range and takes anappropriate action, for example, setting a state variable and (ifappropriate) adjusting range and value as shown in the referencepseudocode listing (2100) of FIG. 21. Then, the decoder (if appropriate)renormalizes (2240) range and adjusts value, using unrolled loop logic(and potentially a lookup table) that maps different values of range todifferent shift amounts. The decoder traverses the unrolled loop logic,checking various common cases for the current range to find anappropriate shift amount. The decoder can then shift range and value bythe shift amount. If the current range is not one of the common casesand uncommon cases are addressed with a lookup table, the decoder looksup the range in the table.

In some implementations, the loop logic for the renormalization stage isat least partially unrolled and goto statements are inserted as neededto break out of the unrolled loop. In particular, the unrolled looplogic is structured (e.g., as a cascade of if/then statements or as acase statement) to exploit a nearly uniform probability distributionthat CABAC produces in the respective bits of range in many codingscenarios. The range is represented as a 9-bit number, and therenormalization effectively shifts the range as needed to make rangehave a top bit of 1. Within range, there is a near uniform expecteddistribution of is and Os, and each bit essentially has a 50% chance ofbeing a 1. With this probability distribution pattern, about 50% of thetime the top bit is 1 and there is no shift. Zero is the most commonshift value. If the top bit is 0 (which happens about 50% of the time),the next bit is 1 about half that time (25%) and there is a shift of 1.Similarly, there is a shift of 2 about 12.5% of the time, and a shift by3 about 6.25% of the time. More generally, there is a shift by n bitsabout ½″ of the time.

In practice, the actual probability distribution is rarely exactlyuniform. The range is not allowed to be 0, and the shift is never bymore than 7 bits at a time. The general distribution allows for designof efficient, partially unrolled loop logic addressing common cases(e.g., 97% of the time the shift will be 4 bits or less). The remainingcases can be addressed with a range lookup table indicating dynamicshift amounts. Mis-predicted branches are expensive, so after 4mis-predicts the cost of the dynamic shift is more acceptable.

E. State Machines for Decision Trees.

The functions that call the core decoding function represented in FIG.21 conventionally have complicated conditional logic around calls to thecore decoding function. The complicated logic in the calling functionsoften results in cache misses and other performance inefficiencies dueto lack of compact code.

According to another aspect of the CABAC decoding innovations, a decoderuses one or more state machines that call a core decoding function forcontext-adaptive binary arithmetic decoding. A state machine implements,for example, a cascade of conditional logic for a particular decodingfunction. In some implementations, a state machine uses a position stateto effectively track position in the cases of conditional logic, and ituses a transition table to switch between states. For example, thetransition table indicates a next state based at least in part upon acurrent state and results of a call to the core decoding function.

FIG. 23 shows a technique (2300) for performing context-adaptive binaryarithmetic decoding using a state machine that implements a callingfunction. A decoder such as the one described above with reference toFIG. 2 or other decoder performs the technique (2300).

The decoder sets (2310) a state machine for the calling function,initializing it, and determines (2320) a state to be passed to the coredecoding function. The decoder calls (2330) the core decoding function(e.g., the function shown in FIG. 21, or a modified version thereofincorporating one or more other CABAC implementations). The decoder thenanalyzes (2340) results of the core decoding function and determines anext state for CABAC decoding. For example, the decoder uses the currentstate and results of the core decoding function to determine a nextstate. The decoder determines (2350) whether or not to continue and, ifso, continues by determining the next state, which is then used incalling the core decoding function.

In some implementations, the decoder replaces complicated cascades ofconditional logic with straightforward loops in state machines. For aparticular state machine, the decoder marks “position” in the cascadethat is reflected in the state machine (where the position iseffectively the state in the decision tree of the cascade) using a statevariable. The state machine can have a two-dimensional transition tablethat indicates to the decoder a new state based on the current state andthe results of the most recent call to the core decoding function.Replacing complicated conditional logic with a state machine typicallyimproves the compactness of code. The branch that remains (the top ofthe loop) is more reliably predicted. This is especially valuable onprocessors that show a significant performance penalty for branchmis-predictions. For example, a 50-line cascade of conditional logicwith 25 calls to the core decoding function is replaced with a 5-lineloop and known number of calls for a state machine, resulting in muchmore compact code.

Moreover, in some implementations, the size of a state table is reducedby exploiting patterns within the state table. For example, for a statetable with x entries, if entries 0 to 3 are the same, entries 4 to 7 arethe same, and so on, the decoder masks off those bits and performs statetransitions based on the remaining bits in a state table with x/4entries.

F. Separate Decoding Units for Different Frequency Intervals.

Transform coefficients for motion-compensated prediction residuals tendto have non-zero values as the DC coefficient and low frequency ACcoefficients, with higher frequency ranges being characterized by runsof zero-value coefficients. Therefore, transform coefficients aretypically scanned according to a scan pattern which orders thecoefficients to take advantage of run length coding or run level coding.

According to another aspect of the CABAC decoding innovations, a decodersplits context-adaptive binary arithmetic decoding for frequencycoefficients into multiple decoding units, each of the units beingadapted for a different frequency interval for the frequencycoefficients. For example, the multiple decoding units include a firstunit adapted for a low frequency range and a second unit adapted forhigher frequency range. Alternatively, the decoder uses more decodingunits and frequency ranges. The units call a core decoding function.

The different units differ in the probabilistic expectationsincorporated into the logic for the units. For example, for a lowfrequency unit, code is adapted for the AC coefficients being non-zero.The non-zero cases are the first cases in the decision trees for thecode. For a high frequency unit, code is adapted for AC coefficientsbeing zero. These are the first cases in the decision trees for thecode. More generally, low cost branches are followed for expectedvalues, and higher cost branches are followed, as needed, whenunexpected values are encountered. Splitting CABAC decoding intomultiple units results in each unit being more compact and moreefficient in processing of calls to the core decoding function.

FIG. 24 shows a technique (2400) for performing context-adaptive binaryarithmetic decoding split into different units for different frequencyranges of coefficients being decoded. A decoder such as the onedescribed above with reference to FIG. 2 or other decoder performs thetechnique (2400).

The decoder calls (2410) a core decoding function (e.g., the functionshown in FIG. 21, or a modified version thereof incorporating one ormore other CABAC implementations) and analyzes (2420) results of thecall using frequency range-specific logic. The decoder checks (2430) ifit is done and, if not, checks (2440) whether to switch therange-specific logic used in CABAC decoding. If not, the decodercontinues by calling (2410) the core decoding function. Otherwise, thedecoder switches (2450) the range-specific logic used in CABAC decodingand continues by calling (2410) the core decoding function.

In one implementation, the decoder switches from low frequencycoefficient decoding logic to higher frequency coefficient decodinglogic after the decoder decodes a DC coefficient and the first three ACcoefficients for a block. Alternatively, the decoder switches at adifferent position and/or dynamically varies the switchover point.

G. Hardware-Specific Optimizations.

In code for one implementation, developers may use preprocessorconditionals, macros and other standard mechanisms to switch betweenusing different CABAC decoding features, and different combinations ofCABAC decoding features, for different target architectures. One simpleexample of this is switching between using a lookup table and not usinga lookup table when determining the result of processing a 5-bit inputvalue. The relative speeds of the operations used for table lookups canvary depending on architecture; the decision about whether or not to uselookup tables can be architecture dependent. Moreover, when making suchdecisions, the primary consideration can be computational speed ofdecoding, memory footprint, or some combination of the two.

VII. Trick Play Mode Innovations.

Some playback devices provide only a simple playback mode at normalspeed, along with controls like play, pause and stop. More advancedplayback devices support trick play modes such as fast forward, fastbackward (rewind), slow forward, slow backward, and chapter selection.The implementation of these trick play modes can vary from device todevice. Chapter selection is typically handled by a parser module in thedevice. Slow forward mode can be implemented by timestamp management.Other playback modes may use support from the video decoder.

In some embodiments, a decoder supports one or more trick play modes (inaddition to a normal play mode) using an innovative trick play modeframework. For example, the decoder supports fast forward and fastbackward modes. In normal play mode, the decoder plays back video at thespecified frame rate for the video. For fast forward trick play mode,the decoder skips decoding and displaying of selected pictures toachieve fast forward effects, which can allow users to have a quick viewof the video. For fast backward trick play mode, the decoder seeksbackward in the bit stream and selectively decodes and displays picturesto achieve fast backward effects, which allows users to view the videoas it rewinds.

A. Example Frameworks for Playback Mode Transitions.

FIG. 25 shows a framework (2500) for playback mode transitions for adecoder that supports normal play mode (2510), fast forward mode (2520)and fast backward mode (2530). In the framework (2500), the decoder canswitch from normal play mode (2510) to fast forward mode (2520), play infast forward mode (2520), then switch back from fast forward mode (2520)to normal play mode (2510). The decoder can also switch between normalplay mode (2510) and fast backward mode (2530), or switch between fastforward mode (2520) and fast backward mode (2530).

In the framework (2500) of FIG. 25, the decoder decodes and displaysonly I pictures in the fast forward mode (2520) and fast backward mode(2530). The I pictures are independently decodable, and their displayorder is the same as their order in the coded video bit stream. At abasic fast forward (or fast backward) rate, the decoder decodes anddisplays regularly spaced I pictures in the bit stream. Or, for adifferent fast forward (or fast backward) rate, the decoder skips thedecoding and display of some proportion of I pictures. For example, thedecoder decodes/displays alternating, regularly spaced I pictures for 2×fast forward (or fast backward) effect. Or, the decoder decodes/displaysevery fourth I picture in a series with regularly spaced I pictures for4× fast forward (or fast backward) effect. The decoder can similarlyselectively decode/display pictures for 3×, 8× or other speedup effects.

According to the framework (2500) shown in FIG. 25, when the decodertransitions between modes, the decoder “drains” so as to facilitate thetransfer. FIG. 26 shows a generalized technique (2600) for switchingplayback modes. A decoder such as the one described above with referenceto FIG. 2 or other decoder performs the technique (2600).

The decoder decodes (2610) video in a first playback mode and receives(2620) a mode switch command. For example, while decoding video innormal play mode, the decoder receives a command to switch to fastforward or fast backward mode. Or, while decoding video in fast forwardmode, the decoder receives a command to switch to normal play or fastbackward mode. Alternatively, the decoder switches between other and/ordifferent play modes.

The decoder drains (2630) the decoder. This involves using up previouslyreceived input, releasing decoder resources, and/or completingin-process tasks. For example, the decoder stops input to the decoderand consumes the input it has previously accepted in the first playbackmode. As another example, the decoder releases memory used for decodingin the first playback mode and/or waits for working threads for thefirst playback mode decoding to complete their processing and rest. Insome implementations, the draining is partial in that the decodermaintains resources (e.g., allocated structures, previously decodedpictures) from the first playback mode that can be reused in the secondplayback mode.

After the decoder at least partially drains (2630), the decoder decodes(2640) video in the second playback mode. Example transition mechanismsand playback mechanisms are now described.

B. Example Playback Mode Transitions.

In some implementations, the decoder switches from normal play mode tofast forward mode as follows. The decoder is drained by not feeding anymore bits from the coded video bit stream to the decoder, and lettingthe decoder decode the data already received in normal play mode. Theworking threads automatically die when there are no more decoding tasksto perform in the decoder. The decoder is not closed, however, eventhough the working threads are at rest, so at least some of the memorypools available to the decoder can be used when the decoder startsagain. One the working threads are dead or there are no more decodingtasks to perform in the decoder, the decoder restarts the workingthreads.

The decoder (or a parser outside the decoder) parses new input from thecoded video bit stream. When the fast forward mode is implemented bydecoding and displaying only I pictures, the decoder gets access unitsthat are used for I pictures. According to the H.264 standard, thisincludes SPS NALUs, SEI NALUs, PPS NALUs and slice NALUs.

After restarting working threads and accepting access units for thevideo to be decoded, the decoder finds complete pictures to decode inthe fast forward mode. For example, the decoder process NALUs for Islices to find complete I pictures using a PED module such as describedabove. The decoder then decodes the complete pictures.

When the fast forward mode is implemented by decoding and displayingonly I pictures, the decoder can simplify processing by bypassingcertain DPB management routines. The decoding order of the I pictures isthe same as their output/display order, and I pictures do not use otherpictures for reference. Therefore, the decoder need not buffer Ipictures in the DPB in the fast forward mode. Decoded I pictures aresimply output and deleted. For example, when PED finds a complete Ipicture, output and delete picture commands are recorded in the picturecommand queue. Generally, picture commands have corresponding dependentpictures entered in a DPB, and the commands are executed when decodingis completed the respective dependent pictures. In fast forward mode,however, picture commands for I pictures need not have correspondingpictures in a DPB, and DPB management routines can be bypassed. When anI picture is decoded, the output and delete commands for it areexecuted. Or, the decoder skips the use of the picture command queue andjust outputs and deletes the I picture upon completion of decoding.

In some implementations, the decoder switches from fast forward mode tonormal play mode as follows. The decoder is drained, finishing decodingfor the fast forward mode data. The decoder then starts accepting datafrom the bit stream in normal play mode and begins decoding. For atransition period, there may be problems decoding and displaying certaintypes of content. The decoder can use special transition mechanisms tosmooth and otherwise improve the quality of playback across thetransition.

Macroblocks in some pictures after an I picture in coded/decoding ordermay reference pictures that were not decoded because they were skippedin the fast forward mode or transition. For example, a B picture (or Ppicture) after the I picture in coded order can reference a I or Ppicture before the I picture in presentation order, which is notcurrently available. If a B picture (or P picture) follows the first Ipicture in coded order, for example, but references a picture that isnon available, the B picture (or P picture) will have corrupted blocksif the decoder attempts to decode it. Rather than attempt to rendercorrupted blocks, the decoder detects whether a picture being decodeduses any unavailable pictures for reference. If so, the decoder skipsdecoding and displaying the picture. If another, later picture in codedorder uses the skipped picture for reference, the decoder also skipsdecoding and display of that other picture. B and P pictures havingavailable reference pictures are decoded and displayed as normal.

There may also be P pictures in the coded video bit stream thatreference a first I picture but have presentation times before the firstI picture. According to the H.264 standard, presentation time stamps(“PTSs”) accompany I slice NALUs, and picture display order may bedifferent from coded order for I and P pictures. For such a P picture,the decoder performs backward interpolation using the PTS of the first Ipicture and the current playback rate.

In some implementations, the decoder switches between normal play modeand fast backward mode using mechanisms analogous to those described fornormal play/fast forward mode transitions. When switching to fastbackward mode, the decoder drains and starts to input data for fastbackward mode, in effect “rewind” seeking through the coded video bitstream. In fast backward mode, the decoder uses mechanisms analogous tothose used in fast forward mode, for example, decoding and displaying Ipictures, and the decoder can use analogous mechanisms to switch fromfast backward mode back to normal play mode.

In some implementations, the decoder switches between trick play modes(e.g., fast forward to fast backward, or vice versa) using analogousmechanisms. For example, when switching, the decoder drains and startsto input data for the other trick play mode.

C. Reducing Delay in Playback Mode Transitions.

Another aspect of the trick play mode innovations is reduction oflatency when switching from normal play mode to trick play mode. Whenswitching to a trick play mode, a long delay (e.g., 4-5 seconds) mightirritate the user. The decoder uses any of several different mechanismsto reduce delay when transitioning to a trick play mode. Collectively,these mechanisms can significantly reduce delay when switching fromnormal play mode to a trick play mode (e.g., reducing a 4-5 second delayto a less than 2 second delay).

For one mechanism, when the trick play mode decodes only I pictures, thedecoder reduces the amount of time it takes to identify complete Ipictures. In some implementations, there is a significant time interval(e.g., 300 ms) between reading the data for different I pictures, due todelays in reading and parsing. The decoder typically identifies (e.g.,during PED) the end of a complete I picture after the decoder parses thefirst slice of the picture following the I picture. According to thefirst delay-reduction mechanism, however, the decoder receivesinformation from decoder wrapper layer software (e.g., MF pipelinesoftware) that indicates where pictures end and facilitatesidentification of I pictures. The decoder wrapper layer software mightget this information, for example, from extra bit stream delimitersbefore and after I pictures. The decoder can begin decoding of thecomplete I picture without waiting for the first slice of the nextpicture, which reduce overall latency (e.g., saving 300 ms).

According to a second delay-reduction mechanism, the decoder bypassesthe DPB for decoded pictures. Instead, decoded pictures are put directlyin an output buffer.

According to other delay-reduction mechanisms, the decoder changessystem parameters to tune performance for the trick play mode. In thetrick play mode, the decoder typically attempts to reduce delay betweenthe completion of decoding and output. So, the decoder can reduce theoutput buffer size. For example, the decoder reduces the output buffersize from 8 pictures to 2 pictures. The decoder can also reduce themaximum number of pictures in flight during multithreaded decoding.

FIG. 27 shows a generalized technique (2700) for reduced-latencyswitching to a trick play mode. A decoder such as the one describedabove with reference to FIG. 2 or other decoder performs the technique(2700).

The decoder reduces (2710) output buffer size. For example, the decoderchanges the output buffer to hold 2 pictures instead of 8 pictures,which speeds up the processes of writing to and reading from the buffer.When finding an I picture to display, the decoder uses (2720) extradelimiters in the bit stream to find complete I pictures faster. Thedecoder then decodes (2730) the complete I picture and puts (2740) thedecoded I picture directly in the output buffer, skipping the DPB. Thedecoder determines (2750) whether to continue and, if so, continues byfinding (2720) the next I picture. Alternatively, the decoder uses otherand/or additional mechanisms to reduce latency when switching to a trickplay mode.

VIII. Innovations in Recovery Using Picture Dropping.

Many video decoders drop pictures in stress conditions such as thoseoccurring when a decoder falls behind during real-time decoding.Software decoders, in particular, usually support picture dropping sincethe software may be used on hardware configurations of varyingcapabilities, including hardware configurations likely to encounterstress conditions during decoding.

In decoders operating according to some standards (e.g., MPEG1, MPEG2),simple picture dropping strategies select pictures to drop based onpicture type. In such standards, picture dependencies tend to be simplerand short term. Typically, P pictures depend on I pictures or other Ppictures, and B pictures depend on I pictures and/or P pictures but noton other B pictures. Moreover, the reference pictures used for a given Por B picture are implied or selected from very limited set of availablepictures. According to one simple picture dropping strategy, a decoderdrops B pictures to reduce decoding complexity when the decoder fallsbehind in real-time decoding.

On the other hand, in decoders operating according to other standards(e.g., H.264), simple picture dropping strategies may be inadequate. TheH.264 standard allows complex picture dependencies. An 8×8 block in apicture can use up to two different reference pictures, and the picturecollectively can use up to 16 frames in a DPB as reference pictures.Moreover, the H.264 standard also allows extensive temporal predictionsupport. The H.264 standard recognizes two kinds of reference pictures,long term and short term. Long term reference pictures can be stored ina DPB and used as reference pictures indefinitely (or at least untilexplicitly removed from the DPB by changing how flags for the long termreference pictures are marked).

A. Example Frameworks for Switching Picture Dropping Modes.

In some embodiments, a decoder uses picture dropping schemes that workfor bit streams with complex reference picture dependencies and/or workfor multithreaded decoding.

FIG. 28 illustrates a software architecture (2800) for an examplepicture dropping approach. The architecture (2800) includes a decoder(2810), wrapper software (2820), and a renderer (2830). The decoder(2810) can include a PED module (2811) as well as other decodingmodules. FIG. 28 shows a processing path for a single picture. Inpractice, the decoder traverses the path on a picture-by-picture basis.

In the architecture (2800), the decoder (2810) (e.g., PED module (2811))parses (2812) a picture from a coded video bit stream. For example, thePED module (2811) finds a complete picture as described above using alightweight scan through the bit stream, initializing structures for theparameters and data for the picture and entering an initialized pictureinto the DPB. Alternatively, the decoder finds the picture in some otherway.

The decoder also determines (2814) whether to drop the picture. In FIG.28, the PED module (2811) receives a control signal that indicates apicture dropping mode, and the PED module (2811) determines whether todrop the picture according to the picture dropping mode. Example picturedropping modes (including no picture dropping) are described below.Alternatively, the decoder uses other and/or additional picture droppingmodes.

If the picture is dropped, the decoder recycles (2816) the droppedpicture. For example, the decoder releases memory used for at least someof the structures initialized for decoding the dropped picture. Droppinga picture may cause one or more other pictures to get dropped, if thoseother pictures are dependent on the first dropped picture.

If the picture is not dropped, the decoder decodes (2818) the picture.In the wrapper (2820), which may provided by DirectShow or MediaFoundation Transform software, the decoded picture is delivered (2822)to the renderer (2830), which displays (2832) the decoded picture.

The renderer (2830) and wrapper (2820) software also cooperate toprovide feedback to the decoder (2810) for selection of a picturedropping mode. For example, decoder wrapper software (in a decoder DLLalong with the decoder) checks timestamps in an output pipeline and,over time, tracks whether the decoder's output rate is keeping up withthe desired presentation rate. The decoder wrapper instructs the decoderabout how late pictures are being output by the decoder (e.g., withmessages that the decoder is not late, 50 ms late, 100 ms late, etc.).Alternatively, the decoder receives feedback or measures progress usinganother mechanism.

When decoding and/or rendering speed does not support the requireddisplay/output speed, the decoder starts to drop pictures. Depending onhow slow the decoding and/or rendering speed is (e.g., how late picturesare being delivered to the renderer), different picture dropping schemescan be selected. The decoder does not decode dropped pictures, so thedecoder tends to catch up to the display/output speed (or, equivalently,catch up to the render clock) when pictures are dropped. More aggressivepicture dropping schemes more quickly help the decoder catch up, but doso at a higher cost to temporal quality. Less aggressive picturedropping schemes have a smaller quality penalty but do not help thedecoder catch up as quickly. As a theoretically matter, the decoderbalances the goals of minimizing the quality penalty for frame droppingand trying to make the decoder return to normal speed playback as soonas possible.

B. Example Picture Dropping Mode Switching Techniques.

FIG. 29 shows a generalized technique (2900) for switching picturedropping modes. A decoder such as the one described above with referenceto FIG. 2 or other decoder performs the technique (2900).

The decoder selects (2910) a picture dropping mode and decodes (2920) inthe selected picture dropping mode. Initially, the decoder can select a“no dropping” mode. The decoder continues decoding for a fixed number ofpictures in the selected mode. Alternatively, the decoder continuesdecoding indefinitely until interrupted by a control signal or the endof the bit stream.

Eventually, the decoder determines (2930) whether to switch modes. Forexample, the decoder receives a control signal and decides whether tochange picture dropping mode to another mode indicated by the controlsignal. Or, the control signal indicates a latency value or othermetric, and the decoder switches selects the picture dropping mode basedupon the control signal, more aggressively dropping pictures as needed.The decoder can gradually switch modes from less aggressive to moreaggressive, for example, switching one mode at a time, or the decodercan switch in proportion to the extent the decoder needs to catch up.Alternatively, the decoder makes the switching decision in some otherway.

If the decoder decides to continue but switch picture dropping modes,the decoder selects (2910) the new picture dropping mode. Otherwise, thedecoder determines (2940) whether to continue at all. If the decoderdecides to continue in the same picture dropping mode, the decoderdecodes (2920) more video in the same picture dropping mode.

C. Example Picture Dropping Modes.

In some implementations, the decoder selects from among the followingavailable picture dropping modes. Alternatively, the decoder selectsfrom among other and/or additional picture dropping modes.

In “no dropping” mode, the decoder does not drop any pictures. Ifdecoding speed is fast enough, the decoder does not drop any pictures;it tries to decode and display all of the pictures.

The decoder may tolerate some consistent amount of delay. In view of thelong latency between the start of decoding of a picture and the sendingthe decoded picture to render, the decoder may keep output pictures in acircular buffer. When the output circular buffer is initially filled,the decoder sends decoded pictures as output for display. Keepingpictures in the output circular buffer can improve the user experienceby ironing out short term variations between decoding speed andoutput/display speed.

In “drop non-reference pictures” mode, the decoder drops pictures thatare not used as reference pictures. If decoding speed is slower thanrequired, the “drop non-referenced pictures” mode provides a gradual wayto start dropping pictures. An H.264 decoder can use information in thecoded video bit stream for a picture/slice to determine whether or notthe picture/slice is used for reference. For example, after the decoderparses the data/NALU for the picture/slice, the decoder evaluates theused_for_reference flag for the picture/slice and drops thepicture/slice if used_for_reference is false. For a picture thatincludes multiple slices, the picture is not used for reference if noneof the multiple slices is used for reference.

In “drop B pictures and dependents” mode, the decoder drops B picturesas well as pictures that depend on the B pictures for reference. Forexample, if the decoding speed in “drop non-reference pictures” modestill does not catch up to the desired output/display speed, the decoderdrops B pictures and their dependents. For an H.264 decoder, a B pictureis a picture where all of the slices in the picture are B slices, and aB picture-dependent picture uses at least one B picture as reference. Inmost coding scenarios, B pictures are rarely used as references forother pictures. B pictures are common, however, for patterns such as thegroup of pictures (3000) shown in FIG. 30. Thus, dropping B pictures andtheir dependents more aggressively helps the decoding sped catch up tothe output/display speed.

In “drop P pictures and dependents” mode, the decoder drops P picturesas well as pictures that depend on the P pictures for reference. Forexample, if, after trying the “drop B pictures and dependents” mode, thedecoding speed is still too slow, the decoder drops P pictures and theirdependents. For an H.264 decoder, a P picture is a picture where all ofthe slices in the picture are P slices, and a P picture-dependentpicture uses at least one P picture as reference. In typical codingscenarios, P pictures and their dependents are common, and many picturesare usually dropped in this mode.

In “I pictures only” mode, the decoder decodes only I pictures and dropsall other pictures. For an H.264 decoder, an I picture is a picturewhere all of the slices in the picture are I slices. In typical codingscenarios, I pictures occur periodically (e.g., every 12 or 15pictures), and many pictures are dropped in this mode.

Finally, in an “IDR pictures only” mode, the decoder only decodes Ipictures that are also IDR pictures, and the decoder drops non-IDRpictures. For an H.264 decoder, an IDR picture is a special I picturethat effectively acts as the beginning of a new sequence. When thedecoder encounters an IDR picture (e.g., from the flag idr_flag), itsignals to the decoder that none of the previously decoded pictures isused as a reference picture going forward. In some coding scenarios, anIDR picture appears every 5 seconds. In other coding scenarios, however,IDR pictures are not used.

D. Example Dependency Tracking for Picture Dropping Decisions.

In some implementations, a decoder creates a dependency trackingstructure (e.g., a task dependency graph) to track referencerelationships for picture dropping schemes. For example, the decoderuses a task dependency graph that associates decoding stages withsegments of video for nodes and tracks dependencies between the decodingstages for the segments. Some of the tracked dependencies indicatereference picture relationships. Alternatively, the decoder uses anothertype of dependency tracking structure.

The decoder uses the dependency tracking structure for some types ofpicture dropping decisions. In the “drop B pictures and dependents” mode(or “drop P pictures and dependents” mode), the decoder identifiespictures that use B (or P) pictures as reference pictures. When adecoder builds a dependency tracking structure, dropped B pictures (or Ppictures) are marked as skipped or dropped in the tracking structure,and the decoder propagates the skipped/dropped status to pictures thatwould otherwise attempt to use a dropped picture as a reference picture.The decoder skips decoding of dropped/skipped pictures, but decodes andoutputs other pictures.

E. Using DPB in Picture Dropping Modes.

According to another aspect of the picture dropping innovations, adecoder integrates its picture dropping approach with DPB management.For example, the decoder tracks the pictures in a coded video bitstream, regardless of whether they are eventually decoded or skipped, ina DPB and picture command queue. This helps the decoder maintain properoutput timing even when pictures are dropping in different picturedropping modes.

FIG. 31 shows a generalized technique (3100) for managing a DPB whileselectively dropping pictures. A decoder such as the one described abovewith reference to FIG. 2 or other decoder performs the technique (3100).

During decoding (e.g., during PED), the decoder finds (3110) a completepicture and enters (3120) the initialized picture in a DPB. For example,the decoder parses the coded video bit stream for parameters for thepicture, initializes structures for the parameters and data for thepicture, and puts an initialized picture container entry for the picturein the DPB, as described above. The decoder can also put picture commandqueues associated with the picture in a FIFO queue.

The decoder (e.g., during PED) determines (3130) whether the picture isdropped/skipped or not. If the picture is not skipped/dropped, thedecoder decodes (3140) the picture and outputs (3150) the decodedpicture. The non-dropped picture is processed as normal during decodingand DPB management, with the non-dropped picture having a regular entryin the DPB.

If the picture is to be skipped or otherwise designated as a droppedpicture, the decoder need not decode the picture. The decoder marks thepicture as skipped in the DPB and other tracking structures, as needed,and recycles (3160) at least some of the resources allocated to thepicture for decoding, so the resources can be reused. For example, thedecoder releases temporary memory and structures (e.g., PictureHolderstructures) for a skipped picture after the skipped picture is foundduring PED, but the decoder maintains other structures (e.g., theinitialized picture entry in the DPB, a structure holding invalid YUVdata) that are still used for DPB management for picture “bumping”and/or output timing, DPB list formulation, and DPB indexing. For outputafter PED, the skipped/dropped picture is treated is skipped picture arenormally treated, for example, by repeating (3170) another, previouslydecoded picture in place of the skipped picture.

The decoder then determines (3180) whether it should continue with thenext picture and, if so, finds (3110) the next picture. For example,after the decoder finishes PED for a skipped picture, the decoder startsPED again for the next picture in the coded video bit stream. To processa long series of skipped pictures, the decoder effectively calls PEDagain and again until a non-dropped picture is found, at which point thedecoder decodes (3140) the non-dropped picture.

Thus, in some implementations, the DPB stores entries for non-droppeddecoded pictures as well as entries for dropped/skipped pictures. TheDPB maintains entries for pictures regardless of whether the picturesare skipped or not. The decoder performs full PED analysis and recyclesresources to improve performance, but also marks dropped pictures asskipped and reserves enough resources to handle dropped pictures asskipped pictures. The decoder does not provide the dropped/skippedpictures to other decoding tasks, since skipped pictures are notdecoded.

IX. Innovations in Computing Contextual Information for Direct ModeMacroblocks.

A direct mode macroblock uses information from a correspondingmacroblock in a collocated picture when determining which motion vectorsto apply in motion compensation. The information from the correspondingmacroblock is an example of collocated macroblock information. In manyencoding scenarios, more than half of the macroblocks in B slices aredirect mode macroblocks, and efficient determination of collocatedmacroblock information is important to performance.

In some embodiments, a decoder uses one or more mechanisms to improvethe efficiency of determining collocated macroblock information. Themechanisms can be used separately or in combination, and several improveperformance in multithreaded decoding.

A. Determining Collocated Macroblock Information as Needed.

According to the H.264 standard, a collocated picture is the firstpicture in a particular reference picture list (namely, LIST1) for a Bslice. The H.264 standard provides algorithmic details about findingcollocated pictures and computing collocated macroblock information,which includes motion vectors and reference indices for macroblocks, aswell as scaling information that applies to macroblocks in a slice.According to the reference software for the H.264 standard, the decodercomputes collocated macroblock information for a picture whether or notany direct mode macroblock actually uses the collocated macroblockinformation from the picture. For example, when a P picture isreconstructed and enters the DPB, the decoder reorders the sideinformation for the picture and makes the side information usable ascollocated macroblock information. This is often an inefficient use ofresources because not all pictures are used as collocated pictures, andbecause collocated macroblock information is computed for a picture butthe picture may never be used as a collocated picture.

In some embodiments, a decoder computes collocated macroblockinformation as needed. For example, the decoder computes collocatedinformation (e.g., retrieves and reorders side information) for apicture when the picture is used as a collocated picture. Moreover, thedecoder can determine whether or not a macroblock of a B slice is adirect mode macroblock and, if so, compute the collocated macroblockinformation (e.g., retrieve and reorder side information) in thecollocated macroblock accessed by the direct mode macroblock. Thedecoder thus retrieves collocated macroblock information that thedecoder will use for the direct mode macroblocks. Computing collocatedmacroblock information as needed for a direct mode macroblockpotentially saves memory compared to approaches in which collocatedmacroblock information is computed for an entire picture or slice.

B. Separating Code to Handle Different Cases of Collocated MBInformation.

In the H.264 reference software, a single routine addresses all cases ofcomputing collocated macroblock information. The logic depends on manyfactors, including the format of the current picture (with the B sliceincluding the direct mode macroblock), the format of the collocatedpicture (with the collocated macroblock), and the direct motion vectorprediction mode (spatial motion vector prediction or temporal motionvector prediction, indicated by the slice-level flagdirect_spatial_mv_pred_flag). For MBAFF frames, in which macroblocks areorganized as macroblock pairs, the logic also depends on the format ofthe MB pair including the direct mode macroblock (field or frame) andthe position of the direct mode macroblock in the MB pair (top orbottom). Given these possibilities, the routine in the H.264 referencesoftware includes too many paths, resulting in too many branches.

In some embodiments, the code that handles different cases for computingcollocated macroblock information is separated. When decodingprogressive video, for example, the decoder determines which routine tocall depending on whether a direct mode macroblock uses spatial motionvector prediction or temporal motion vector prediction. For picturesthat can be fields or frames, the code is split into routines optimizedfor different current picture format/collocated picture format/directprediction mode cases.

The decoder can select and call routines as needed during decoding tocompute collocated macroblock information. For example, the decoderselects and calls an appropriate routine when it identifies a directmode macroblock in a B slice. The decoder thus avoids unnecessarycalculations of collocated macroblock information for a whole collocatedpicture.

FIG. 32 shows routines for computing collocated macroblock informationin PROG and PICAFF code paths in some implementations. The decoderselects a function depending on current picture format (PROG or FIELD),collocated picture format (PROG or FIELD), and direct motion vectorprediction mode (spatial or temporal), then calls the selected function.In the PROG code path, the current and collocated pictures are in frameformat. So, there are only two collocated macroblock informationfunctions, (1) the current PROG picture refers to a PROG picture ascollocated picture and direct mode MBs use spatial motion vectorprediction, and (2) the current PROG picture refers to a PROG pictureand direct mode MBs use temporal motion vector prediction. Similarly, inthe PICAFF code path, there are 6 collocated macroblock informationfunctions covering different permutations.

FIG. 33 shows routines for computing collocated macroblock informationin the MBAFF code path in some implementations. The decoder selects afunction depending on current picture format (MBAFF or FIELD), currentMB pair format (frame or field), position of the direct mode macroblockin the current MB pair (top or bottom), collocated picture format (MBAFFor FIELD), and direct motion vector prediction mode (spatial ortemporal). The decoder then calls the selected function. For the MBAFFcode path, there are 16 collocated functions handling differentpermutations of these factors. An X indicates a factor does not changewhich function is called for some combination of other factors.

Alternatively, the code for computing collocated macroblock informationis separated in other and/or different ways to partition the code tohandle different cases.

C. Computing Collocated MB Information in Multithreaded Decoding.

When computing collocated macroblock information, the decoder uses sideinformation previously reconstructed for the collocated picture. As suchthe retrieval of the collocated macroblock information depends on thesuccessful reconstruction of the information for the collocated picture.

In some embodiments, the decoder puts computation of collocatedmacroblock information in an appropriate stage of the decoding pipelineto improve parallelism for multithreaded decoding. In particular, thedecoder separates computation of collocated macroblock information fromentropy decoding tasks to facilitate multithreaded decoding. A task inwhich collocated macroblock information is computed can thus bescheduled separately from ED tasks.

To compute collocated information for a direct mode macroblock in a Bslice, an H.264 decoder gets side information (motion vectors, referenceindices, etc.) from the first picture in reference picture list LIST1.If the computation of collocated macroblock information is part of an EDtask for the B slice, the ED task for the B slice will have a dependencyon the ED task for the relevant part of the first picture in LIST1(which provides the side information for the first picture). Creatingdependencies between two ED tasks hurts parallelism, however, since EDtasks usually do not have dependencies between them. As anotherconsideration, an MC task for the B slice uses collocated macroblockinformation, so it should be computed before the MC task.

In some implementations, computation of collocated macroblockinformation for a B slice occurs as at the beginning of a MC task forthe B slice. The MC task already has a dependency on an LF task (and,indirectly, MC and ED tasks) for the relevant part of the collocatedpicture.

In other implementations, computation of collocated macroblockinformation for a B slice occurs as part of a separate task for the Bslice. For example, in a GPU architecture, the COLOC task includescomputation of collocated side information (e.g., by retrieving sideinformation) and other GPU setup tasks. The COLOC task can beimplemented, for example, as part of an MV setup task. FIG. 34 shows anexample task dependency graph (3400) that includes tasks for an Ipicture (picture 1), P picture (picture 3) and B picture (picture 2). Inmany respects, the task dependency graph (3400) resembles the graph(1000) of FIG. 10. The graph (3400) also includes a COLOC task forpicture 2, however, which depends on the ED task for picture 3. Ifneeded, the COLOC task for picture 2 can also depend on the ED task forpicture 2. The MC task for picture 2, in turn, depends on the COLOC taskfor picture 2. More generally, the decoder generates a task dependencygraph for segments (which may be pictures) and, in some implementations,separates computation of collocated macroblock information and other GPUsetup operations for scheduling as a separate task.

D. Separately Computing Slice-Level and MB-Level Collocated MBInformation.

In some embodiments, the decoder separates computation of slice-levelcollocated macroblock information from computation of macroblocklevel-collocated macroblock information. This improves performance whenmultiple direct mode macroblocks use the same slice-level collocatedmacroblock information.

FIG. 35 shows a technique (3500) for separately computing slice-levelcollocated macroblock information and macroblock-level collocatedmacroblock information. A decoder such as the one described above withreference to FIG. 2 or other decoder performs the technique (3500).

When processing a B slice, the decoder computes (3510) slice-levelcollocated macroblock information. For example, the decoder retrievescommon side information among the direct mode macroblocks of the Bslice. The common side information can include motion vector scalingfactors, which are the same for the direct mode macroblocks in theslice, and which are used in temporal direct mode. The common sideinformation can also include a field picture selection (which fieldshould be chosen as the collocated picture). Alternatively, the decodercomputes other and/or additional slice-level information.

The decoder then computes macroblock-level collocated macroblockinformation for the direct mode macroblocks in the picture. For example,according to the technique (3500) shown in FIG. 35, the decoder computessuch information as needed during decoding. The decoder gets (3520) thenext macroblock in the slice. The decoder determines (3530) whether themacroblock is a direct mode macroblock and, if so, computes (3540)macroblock-level collocated macroblock information such as motionvectors and reference indices. The decoder determines (3550) whetherthere any other macroblocks in the slice and, if so, continues bygetting (3520) the next macroblock.

The decoder stores the slice-level collocated macroblock information andmacroblock-level collocated macroblock information for use in laterdecoding.

E. Remapping Reference Picture Indices.

A reference index (ref_idx in H.264) in a slice is an index to a picturein a reference picture list of the slice. In different slices, referenceindices with the same value (e.g., 3) may refer to different picturesbecause the reference picture lists for the different slices can bedifferent. When the decoder retrieves collocated macroblock informationfor a direct mode macroblock in a B slice, the decoder determines whichpicture (if any) in the B slice's reference picture list corresponds tothe reference picture used for reference by the collocated macroblockthat provides the collocated macroblock information.

A “per macroblock” way to find the correct reference picture is todetermine a reference picture identifier of the reference picture forthe collocated macroblock when computing the collocated macroblockinformation for a direct mode macroblock. (For example, the decoderdetermines the reference picture identifier using the reference pictureindex for the collocated macroblock.) The decoder compares the referencepicture identifier with the reference picture identifiers of thepictures in the B slices reference picture list. The decoder stops thecomparison when is finds the reference picture used by the collocatedmacroblock. In the worst case in some implementations, if the size ofthe reference picture list is LIST_(size), this involves 4×LIST_(size)64-bit integer comparisons for each direct mode macroblock. In manyscenarios, about 50% of the macroblocks in a B slice are direct modemacroblocks, and performing comparisons for every direct mode macroblockis too computationally intensive.

In some embodiments, on a slice-by-slice basis, the decoder usesremapping techniques to re-enable the reference indices in collocatedpictures to reduce computations and save memory. For example, referenceindices that refer to reference pictures for a collocated slice (whichincludes at least one collocated macroblock for a corresponding directmode macroblock of a B slice) are replaced with reference indices for aB slice that refer to the same reference pictures. The remappedreference picture indices are then stored for use in motion compensationfor the direct mode macroblocks.

For example, when the decoder computes collocated macroblock informationfor a B slice, for each collocated slice in the collocated picture, thedecoder remaps the reference indices for the collocated slice in termsof the reference indices for the B slice. For a reference index of thecollocated slice, the decoder can do this by (a) finding thecorresponding reference picture identifier for the reference pictureindex of the collocated slice, (b) comparing the reference pictureidentifier with identifiers for pictures in the B slice's referencepicture list, and (c) when a matching reference picture identifier isfound in the list, remapping the reference index of the collocated sliceto the reference index of the matching reference picture identifier forthe B slice (e.g., replacing the reference index of the collocated slicewith the corresponding reference index of the B slice). If no match isfound, the reference picture index of the collocated slice is invalidfor direct mode MB motion compensation.

In some implementations, reference picture list size is limited to amaximum of 16 frame pictures or 32 field pictures. The number ofcomparisons is thus limited, and the overall number of comparisons isreduced for typical sizes of B slices with expected proportions ofdirect mode macroblocks.

X. Innovations in Reducing Memory Consumption During Decoding.

Decoding video can consume large amounts of memory resources, especiallyfor multithreaded decoding. In some embodiments, a decoder uses one ormore mechanisms to reduce memory consumption during decoding, including:

-   -   1. packing entropy decoded transform coefficient levels for        efficient buffering;    -   2. dynamically growing packed buffers that stored entropy        decoded transform coefficient levels;    -   3. pairing field pictures to associate the two field pictures        with a piece of frame size memory before decoding them;    -   4. efficiently allocating GPU memory; and/or    -   5. efficiently managing memory pools.

A. Packing Entropy Decoding Coefficient Levels.

After entropy decoding, one way to store entropy decoded coefficientlevels is to store all coefficient levels, whether zero-value ornon-zero-value level, in order in memory. In typical cases, this isinefficient because much storage is spent buffering zero-value levels.

In some embodiments, a decoder “packs” (or “compresses”) entropy decodedtransform coefficient levels for efficient intermediate storage. Thistypically reduces the memory consumed storing the entropy decodedcoefficient levels for a given picture. The aggregate savings in memorycan be dramatic where there are multiple pictures in flight duringdecoding.

When multiple pictures are in flight, the coefficient levels are kept inpacked format until the decoding stage in which the coefficient levelsare further processed. In later decoding processes such as inversescanning, inverse quantization, and inverse transform, the entropydecoded coefficients are unpacked into a less compact representationthat is easier to manipulate for those operations. The unpacking can beimplemented in conjunction with inverse scanning and/or inversequantization.

In some implementations, the decoder packs entropy decoded coefficientlevels into data structures by storing a block position together with anon-zero level value for each non-zero coefficient level. The decoderpacks the block position and non-zero level value into a singlemulti-bit value to save memory. Arrays of the single multi-bit valuesstored multiple non-zero coefficient levels for a block, macroblock, orother unit. Non-zero values are not explicitly represented in theintermediate storage. Instead, the zero-value levels are implied atparticular block positions where no values are stored for thoseparticular block positions. In typical coding scenarios, in which highfrequency coefficients are often zero, this representation candramatically reduce intermediate storage requirements.

If the single multi-bit value does not include enough bits to store somepossible value, the single multi-bit value can include an extension flagthat indicates whether an extension value is used for the coefficientlevel. If an extension value is used, part of the non-zero coefficientlevel is stored in the single multi-bit value, and the rest is stored inthe extension value. To simplify manipulation of the coefficient levels,the extension value can follow the single multi-bit value and have thesame size.

With another option, the decoder stores a count value for a block (e.g.,4×4 or 8×8 transform block) that tracks how many non-zero coefficientlevels are in the block. The decoder can store the non-zero coefficientcount values for the blocks in a macroblock in an auxiliary buffer,together with the count values for blocks of other macroblocks. Usingnon-zero coefficient count values provides an efficient way to representzero-value blocks. It also can help the decoder access packedcoefficient levels more efficiently by skipping ahead to the start of aparticular block. If extension values can be interspersed with othervalues in the packed data, however, the decoder still traverses thepacked data in a coefficient-by-coefficient manner to get the start of ablock.

With another option, the decoder sets a flag per macroblock indicatingwhether extension flags are set for any coefficient levels in themacroblock. If no extension flags are set in the macroblock, noextension values are used, and the decoder can skip checking forextension flags in individual non-zero coefficient levels. The decodercan also make simplifying assumptions about block start locations in thepacked data, for example, using counts of non-zero coefficient valuesfor blocks in the macroblock.

FIGS. 36 and 37 show example data structures for packing entropy decodedcoefficient levels. In FIG. 36, the 16-bit short (3600) stores a packedcoefficient level for a CABAC decoded transform coefficient level thathas a non-zero value. The packed buffer fragment array (3610) is anarray of such short values.

The multi-bit value (3600) includes a 6-bit position value, extensionflag, and 9-bit non-extended, non-zero value of the coefficient. Thelower 6 bits of the value (3600) store the location of the coefficientwithin a 4×4 or 8×8 block. (Six bits are enough to store the 64 possiblelocation values of an 8×8 block.) The seventh bit is an extension bitthat stores a 0 or 1 value indicating whether this coefficient has anextension value. The remaining 9 bits of the value (3600) store the 9least significant bits of the coefficient level. In case 9 bits are notenough to store the coefficient level, the extension bit is set to 1,and 16 additional bits are used to store the remaining bits required torepresent the coefficient value. 16 additional bits may be more than areneeded, but using the same number of bits as the value (3600)facilitates representation as an array (3610) of shorts with extensionvalues interspersed as needed.

FIG. 37 shows an auxiliary array (3710) of block count values for themacroblock (3700). A block count values indicates the count of non-zerocoefficient levels in a corresponding block of the macroblock (3700).For example, the block 5 count indicates the number of non-zerocoefficient levels of 4×4 block 5 in the macroblock (3700). The array(3710) can be implemented as a char buffer. There are a maximum of 24possible blocks within a macroblock (16 4×4 luma blocks and 8 4×4 chromablocks, assuming 4:2:0 macroblock format; for 8×8 blocks there are 6blocks in a macroblock).

An array (3720) of block count auxiliary arrays (such as the array(3710)) stores non-zero coefficient count values for multiplemacroblocks. For an entire picture, the auxiliary buffer array (3720) isat least as large as 24×MB_IN_PIC bytes, where MB_IN_PIC is the numberof macroblocks in the picture. The auxiliary buffer array (3720) for apicture can be partitioned at the slice/segment-level and navigated to acurrent location by: current location=auxiliary buffer baselocation+24*(starting macroblock address of slice/segment). Thisfacilitates access by multiple ED threads to the buffer at the sametime.

After CABAC decoding of the coefficient levels within the sub-blocks andblocks of the macroblock (3700) in a given plane (Y, U or V), anadditional bit is set to indicate whether any coefficients within theblocks uses an extension value. This flag makes decoding much fasterwhen none of the coefficients uses an extension value.

Using compressed storage as shown in FIGS. 36 and 37 can providesubstantial memory savings. These savings are especially important formultithreaded decoding when multiple frames are in flight. For example,for test sequences of high-definition content at 1920×1088 spatialresolution, the storage requirements are cut down from 6 megabytes(uncompressed storage) to about 0.75 megabytes (compressed, packedstorage) per picture. A large proportion of this reduction is due toskipping of storage for insignificant, zero-value coefficient levels,which are common. Moreover, in practice, most coefficient levels fitwithin 9 bits—the use of extensions is rare.

In the worst case, if every coefficient level has a non-zero value andneeds an extension, there are 64 non-zero levels per 8×8 block and 64extension values. The amount of storage used is double the amount usedfor uncompressed storage. Such situations are extremely rare, but thedecoder keeps memory available in case it is needed.

B. Dynamically Growing Packed Buffers.

The amount of intermediate storage needed for packed, decodedcoefficient levels varies depending on the complexity of the encodedvideo as well as bit rate and quality considerations. Allocating enoughmemory to a handle worst-case situation is wasteful most of the time,when far less memory is actually used.

In some embodiments, a decoder dynamically grows the buffers used tostore packed coefficient levels. The decoder fills a buffer fragment,for example, level-after-level for a block, block-after-block for amacroblock, and macroblock-after-macroblock for a segment. The decoderchecks for the end of a packed buffer fragment periodically (e.g., bychecking every macroblock whether enough space remains for worst-casemacroblock storage) or otherwise tracks available space in the fragment.If needed, the decoder adds another buffer fragment to fill.

The decoder can allocate buffers on a slice-by-slice basis. If slicesare small and the buffers are mostly unused, however, this is wasteful.Alternatively, the decoder allocates buffers on a picture-by-picturebasis, segment-by-segment basis or other basis.

FIG. 38 shows an example approach (3800) with a set of thread-specificpacked buffers (3810) for segments of a picture and a packed bufferfragment pool (3820). The buffers (3810) handle the storage of packed,compressed coefficient levels for the picture.

The pool (3820) of packed buffer fragments includes fragments such asthe fragment array (3610) of FIG. 36, which is an array of “shorts” thatstore packed coefficient levels. The fragments can all have the samesize, or they can have different sizes. In some implementations, thepacked buffer fragment size is set so that, in most cases, one fragmentis enough to store the coefficient levels decoded in an ED task for asegment.

The pool (3820) includes free fragments available for adding todynamically growing buffers. For example, packed buffer fragments areallocated from the pool (3820) when necessary. When fragments are freed,they are returned to the pool (3820) so that they can be reused forother packed buffers across multiple pictures.

In FIG. 38, a buffer is implemented as a linked list of buffer fragmentsfrom the pool (3820). Separate buffers are created for separate intraand inter passes of decoding. The intra buffer stores intra coefficientlevels, and the inter buffer stores inter coefficient levels.Alternatively, a single buffer stores intra coefficient levels and intercoefficient levels.

In a single threaded mode, two packed buffers (1 intra, 1 inter) perpicture store the coefficient levels. In multithreaded mode, the decodermay decode multiple segments in a picture in parallel. So, the set ofbuffers (3810) includes two packed buffers (1 intra, 1 inter) associatedwith each of multiple worker threads. During an ED task, for example, athread writes only to the buffers associated with it. For other decodingtasks (e.g., MC, INTRA, LF), multiple threads may read from a singlebuffer.

Using thread-specific packed buffers helps delimit different portions ofa packed buffer for different slices in a picture in advance, withoutwasting storage as could easily be the case with slice-specific buffers.Using separate thread-specific packed buffers for segments alsofacilitates segment-level multithreading. The number of threads issmaller than the number of possible slices; organizing buffers in athread-specific manner gives an upper bound on the number of buffersthat are used.

C. Pairing Field Pictures in Frame Memory Buffers

In H.264 reference model software, when a decoder splits a decoded framepicture into field pictures (e.g., to use in later decoding of otherpictures), the decoder allocates memory for the two split field picturesand performs expensive memory copy operations. This is an inefficientuse of memory. A similar problem occurs when two decoded field picturesare combined into a single frame picture for output by allocating memoryfor the frame picture and performing expensive memory copy operations.

In some embodiments, a decoder uses a single frame memory buffer torepresent a video frame as well as two complementary top and bottomfields of the video frame. FIG. 39 shows an example frame memory buffer(3900) for a frame. The frame buffer (3900) includes lines of samplevalues. A buffer structure for the top field (3910) includes pointers tothe even lines of the frame in the frame buffer (3900), whichfacilitates access to the buffered top field. A buffer structure for thebottom field (3920) includes pointers to the odd lines of the frame inthe frame buffer (3900), which facilitates access to the buffered bottomfield. Another buffer structure (not shown) for the entire frame caninclude pointers to all lines of the frame in the frame buffer (3900),facilitating access to the frame as a whole.

The decoder writes fields into an appropriate frame buffer, interleavingthe lines of the field with lines of the complementary field from thestart. This avoids extra memory copy operations from frames to fields,and vice versa, and conserves memory.

When the decoder decodes two complementary field pictures but outputs asingle frame picture, the decoder uses the single frame memory buffer(3900) to efficiently represent the field pictures and frame picture. AnH.264 decoder generally outputs frame pictures even when the framepictures are decoded as field pictures. Parameters in slice headers forthe field pictures indicate whether the two field pictures are a pair ofcomplementary fields. Two field pictures that are a pair are interleavedand put together as a frame picture, not only for output purposes butalso for reference. In some implementations, the functionDetect_Field_Picture_Pair( ) is used to detect whether two fields are apair. When two field pictures are a pair, they satisfy the logic in thisfunction and are adjacent to each other in decoding order.

When two field pictures will share the same frame memory, and thedecoder “pre-interleaves” them. The decoder makes pointers for the topfield picture and bottom field picture point to the even and odd lines,respectively, in the frame size memory. This not only saves theadditional memory for the combined frame picture but also avoids thememory copy operations.

When the decoder decodes a frame picture but splits it intocomplementary field pictures (e.g., in the MBAFF or PICAFF code path, tosplit the frame into reference fields), the decoder uses the singleframe memory buffer (3900) to efficiently represent the field picturesand frame picture. The decoder sets up pointers in the split fieldpictures and makes them point to the even and odd lines in the framepicture. This saves memory for the two split field pictures and save twosubstantial memory copy operations.

D. Efficiently Allocating GPU Memory.

In some embodiments, a decoder (with GPU) uses one or more memory usageinnovations during GPU decoding. Some of these innovations relate to howreference pictures are represented in memory, including:

-   -   representing a reference picture as a texture in memory and        accessing it using texture operations;    -   representing multiple reference pictures as a 3D texture in        memory; and    -   representing complementary field pictures as interleaved lines        of a texture in memory.

Other innovations relate to the timing of memory management in GPUdecoding, including:

-   -   having multiple memory partitions in flight during GPU decoding        for different formats of pictures;    -   having multiple image array slot assignments in flight during        GPU decoding; and    -   more generally, having multiple (potentially inconsistent)        resource usage patterns in flight during GPU decoding.

Alternatively, a decoder uses other and/or different memory usageinnovations during GPU decoding.

1. Innovations in Storing Reference Pictures for GPU Decoding.

One way to represent reference pictures in memory for GPU decoding is tosimply allocate memory and organize the reference pictures in adjacentextents of memory. The reference pictures can then be accessed withnormal memory access operations at their respective locations. For someGPU architectures, this is an inefficient use of memory.

According to one reference picture storage innovation, a decoder (withGPU) represents a reference picture as a texture in memory. Using atexture facilitates hardware support for fast, random access textureoperations across the horizontal (x) and vertical (y) dimensions of areference picture image plane. When the decoder decodes a picture, forexample, the decoder can use the fast texture operations to access thereference picture in memory during motion compensation.

When a decoder (with GPU) uses multiple reference pictures, if themultiple reference pictures are simply put in memory, memory accesspatterns may be inefficient. In one approach to addressing this problem,the decoder sorts the blocks of a current picture being decodedaccording to reference picture used. The decoder performs motioncompensation in multiple passes for the different reference picturesused, one pass per reference picture. For example, in a first pass thedecoder performs motion compensation for blocks that use a firstreference picture, in a second pass the decoder performs motioncompensation for blocks that use a second reference picture, and so on.While this improves memory access patterns, it also involves additionalcomputation and switching between passes.

According to another reference picture storage innovation, a decoder(with GPU) represents multiple reference pictures in an image array as a3D texture. The 3D texture supports fast random access to differentreference pictures along its depth (z) dimension and also supports fastrandom access within individual reference pictures. When the decoderdecodes a picture, for example, the decoder can use the fast textureoperations to access any of the reference picture in memory duringmotion compensation.

According to another reference picture storage innovation, for GPUdecoding, complementary reference fields are stored as alternating rowsof an image plane in a 3D texture. The GPU uses texture operations toaccess the top field (even lines), the bottom field (odd lines), and/ora reference frame including the top and bottom fields (even and oddlines). For example, given a starting row y, the GPU accesses rows inincrements of two (y+2, y+4, etc.) to retrieve sample values for anindividual field. Or, to retrieve sample values for the reference frame,the GPU accesses rows in order from the starting row. In someimplementations, when the GPU performs decoding operations for a givenpicture type (frame or field) or macroblock type (field-coded or framecoded), it automatically accesses the correct rows of the field/framerepresentation to retrieve sample values, incrementing the rows toaccess them appropriately. The field/frame representation efficientlyuses memory for reference pictures by avoiding redundant storage offields and frames (as in the non-GPU implementations). Moreover, whenthe fields/frame are stored as an image plane in a 3D texture for GPUdecoding, it also improves the efficiency of motion compensation bymaking access operations simpler and faster.

2. Innovations in Timing of Memory Management in GPU Decoding.

In many implementations, a GPU (unlike a CPU) is single threaded. TheGPU decodes pictures in coded video bit stream order. The GPU can employparallel processing by splitting up certain decoding tasks (such as aninverse transform) and performing them in parallel for a particularsegment or picture, but from picture-to-picture the decoding occurs inserial order.

For purposes such as resource allocation, even though pictures aredecoded in serial order by the GPU, the decoder scans ahead (e.g., witha CPU using PED) in the coded video bit stream. In some implementations,the decoder orders tasks in a FIFO GPU command queue. Various commandsin the GPU command queue can affect how the GPU uses memory or otherresources. One task at a time and in serial order, the GPU removes tasksand executes primitives for the tasks, potentially changing how the GPUuses memory or other resources.

The GPU command queue can include commands with potentially inconsistentresource usage patterns for multiple pictures in flight during decoding.For example, the decoder can scan ahead in the bit stream throughpictures having different formats (e.g., resolutions), different ways ofidentifying reference pictures in memory, or other different patterns ofusing resources. Resource usage patterns can be inconsistent frompicture to picture, in that they cause the GPU to use the same resourcein different, conflicting ways. Since the GPU removes commands one at atime in serial order, however, the GPU uses memory and other resourcesconsistently for any given task/primitive.

According to one aspect of the GPU resource management innovations, adecoder represents multiple resource usage patterns for multiplecommands in a GPU unit command queue for multiple pictures in flightduring decoding. For example, the resource usage patterns are memorypartitions or slot assignments for reference pictures. The decoderdecodes pictures in serial coded order with a GPU, regulating memorybased at least in part upon the multiple resource usage patterns.

According to another aspect of the GPU resource management innovations,a decoder receives a coded video bit stream that includes encoded videofor multiple pictures in serial coded order. The decoder scans ahead inthe coded video bit stream to determine multiple resource usage patternsfor the pictures and tracks the resource usage patterns (e.g., in a GPUcommand queue that tracks commands and represents the resource usagepatterns). The tracked resource usage patterns include at least someinconsistent patterns in flight during decoding. Typically, each of suchinconsistent patterns is valid during one part of decoding but invalidduring a different part of decoding. For example, the inconsistentpatterns include different memory partitions for reference pictures. Or,the inconsistent patterns include different slot assignments forreference pictures. The decoder (with GPU) performs decoding operationson the pictures in serial coded order (e.g., as reflected in the GPUcommand queue).

As another example of resource usage patterns, the decoder allocatesdifferent data structures for different formats/resolutions of pictures.When decoding finishes for the last picture encountered thus far for aparticular format, the decoder can free memory used for the structuresfor pictures of that format.

a. Multiple Partitions in Flight.

In some embodiments, for memory used by a GPU to store referencepictures, a GPU command queue represents different memory partitions inflight, including potentially inconsistent memory partitions. Thedecoder efficiently allocates and partitions GPU memory based oninformation in a GPU command queue.

In some implementations, a GPU uses an image array to store referencepictures and, potentially, other decoded pictures as well. For example,the decoder allocates an extent of memory to the GPU, and the memory ispartitioned to store 16 standard-definition reference pictures and onestandard-definition picture being decoded. The decoder uses thepartitioned memory when decoding standard-definition pictures of a videosequence, potentially having multiple pictures in flight. Later, thepictures switch to high-definition, and the memory is partitioned tostore four high-definition reference pictures and one high-definitionpicture being decoded. The decoder uses the re-partitioned memory whendecoding the high-definition pictures.

The GPU uses the same image array for either standard-definition orhigh-definition decoding, re-partitioning the memory as appropriate whena new format is encountered. The decoder (e.g., a CPU in a PED stage)tracks format changes and manages the GPU command queue to reflect thechanges. The GPU command queue, which typically includes commands formultiple pictures in flight, can thus include memory partitions forpictures in different formats. The memory partitions may beinconsistent, but the GPU only uses memory partitioned one way (thecorrect partition for current decoding) at a time due to serialexecution of commands from the GPU command queue.

In theory, for some number (e.g., 32) of pictures in flight, theresolution might change several times, even on a picture-by-picturebasis. If pictures could be decoded in any order by the GPU, this wouldcomplicate the management of memory used by the GPU when the memory ispartitioned in different ways for different resolutions of referencepictures. Since the GPU decodes a single picture at a time in codedorder, however, the decoder can more aggressively prune pictures frommemory, compared to multithreaded decoding approaches in which morepictures are buffered.

b. Multiple Slot Assignments in Flight.

In some implementations, the GPU maintains separate reference and outputpictures. The reference pictures are used by the GPU and not output.

When driving a pipelined GPU (multiple pictures in flight), the decoder(e.g., with a CPU in a PED stage) can determine which reference picturesare reused from picture to picture as pictures are scanned andassimilated into the GPU command buffer. When a picture is scanned, thedecoder considers, for example, the picture's private DPB. Work formultiple pictures can be enqueued at one time in the GPU command buffer,and the work can use memory inconsistently. Different commands caninvolve writes to or reads from the same memory location but relate towork for different pictures at the location. The decoder can effectivelyhandle this potential inconsistency because the GPU processes commandsin the GPU command queue in serial, coded order, and there is a maximumnumber of reference pictures (e.g., four for high-definition or 16 forQCIF). Changes to reference picture ordering or assignment are processedserially and according to expected limits on buffer size, whichfacilitates pruning of reference pictures from memory.

In particular, reference indices typically differ at different timesduring decoding. For pictures 0, 1 and 2, for example, picture 0 can usereference pictures A, B, C and D. When work for picture 0 is passed tothe GPU, the decoder marks where picture 0 will be stored after it isdecoded. When picture 0 is decoded, if reference picture A is no longerused in decoding, the GPU writes picture 0 to where picture A was.Because the GPU processes pictures in serial order, the decoder cansafely determine when no other picture relies on reference picture A andreference picture A can be overwritten.

For example, a decoder (with CPU) using PED tracks the state of a DPB atthe point it is parsing in a coded video bit stream. A picture, ineffect, has its own view of the DPB, and the PED stage tracks the liveDPB. With this information, the decoder pre-assigns image array slotsfor pictures for the GPU to use. The decoder essentially decides where anext picture will be stored when it is decoded (e.g., to slot 0, 1, 2,3, 4 or 5). The decoder can also determine when a reference picture isno longer used and thus determine when the reference picture can beoverwritten during serial-order decoding by the GPU. The GPU commandqueue in effect stores references to memory that the GPU will write to,which the GPU may or may not have already written to, but which will beavailable to the GPU when the command in question can execute and callsare made to the memory. The GPU performs work using the prospectivelyassigned slots in the image array, at the appropriate times storingpictures in the appropriate slots in the memory array, accessing thepictures, and overwriting the pictures. This efficient reuse of imagearray slots, as determined by DPB bumping logic in the PED stage,facilitates memory management for the GPU.

E. Efficient Memory Pooling for Multithreaded Decoding.

When a decoder is allocated memory from system heap (e.g., with thememory allocation routine malloc( )), the system heap often becomesfragmented over time. With multithreaded decoding, the problem ofgradual fragmentation can be even worse.

In some embodiments, a decoder imposes memory pool organization on topof a memory heap to reduce fragmentation. When the decoder processes thecoded video bit stream or performs other decoding tasks, it uses memoryfragments of the same size for a particular type of operation. When donewith the data in a memory fragment, the decoder releases the memoryfragment back to the pool.

In some implementations, the decoder uses different pools for differentdata structures, sets of data structures, or decoding tasks. Forexample, suppose that, for a GPU setup task for a picture, the decoderneeds 1 MB of memory for the structures used. Instead of using malloc(), the decoder requests and is allocated an appropriately sized memoryfragment from a pool of such memory fragments for GPU setup tasks. TheGPU task populates the structures in the memory fragment and variousother decoding tasks use the structures. Eventually, the decoderreleases the memory fragment back to the pool, invalidating the data init. From the pool, the memory fragment can be allocated in laterdecoding. Allocation through such memory pools helps reduce memoryfragmentation.

Example memory fragment sizes for PED and ED are 3 MB and 8 MB,respectively. More generally, different pools are specialized fordifferent tasks and types of structures. For the memory fragments,structure lifetime is mapped to lifetime of the data in the structuresin the memory fragment.

XI. Other Innovations.

In some embodiments, a decoder uses other optimizations to improveperformance in certain scenarios. These optimizations have some generalthemes but often are targeted to specific platforms or applications.

According to one optimization, in some implementations, the decoder usesa single-instruction-multiple-data (“SIMD”) structure for an inversetransform according to the H.264 standard. In the H.264 standard, a 4×4inverse transform consists of the same set of instructions beingexecuted on each of the four rows/columns of the block. The transformcan be carried out using 16-bit addition, subtraction and shiftarithmetic.

A 128-bit SIMD performs a maximum of 4 32-bit instructions, 8 16-bitinstructions, or 16 8-bit instructions in parallel. To enhanceparallelism, an entire SIMD vector is used. Since the SIMD vectors canperform 8 16-bit operations at once but the inverse transform uses onlyfour parallel operations for four rows or columns, the decoder combinestwo 4×4 transforms into a single 8×4 inverse transform that uses one setof vector instructions.

Regardless of whether each block consists of sub-blocks of 4×4, 4×8,8×4, or 8×8, the inverse transform is done on the entire 8×8 block. Bycombining the inverse transforms of two 4×X sub-blocks, the number oftransforms done can be reduced by half. Furthermore, because there is nodependency between two adjacent Xx4 sub-blocks within a block, they canbe combined into a single function for more efficient scheduling andless function call overhead. Combining these optimizations allows callsto a single 8×8 inverse transform function for each block, regardless oftype of sub-blocks within each block.

For the memory layout of the buffers used in the inverse transform, asingle vector load per row loads both 4×X sub-blocks in the correctlayout. This reduces the number of vector loads needed for the combined8×8 transform. It also helps avoid additional vector loads andmanipulation for setting the vectors up correctly, which would result inperformance loss.

According to another category of optimizations, branches are eliminatedin the code base of the decoder to improve memory performance. This isdone, for example, by identifying code with numerous branches andreplacing such code with a state machine or table-based lookupmechanism.

According to still another category of optimizations, dynamic shifts(which are costly operations in some architectures) are replaced withother operations. For example, dynamic shifts are identified in the codeand replaced by unrolling conditional logic and/or using a state table.

XII. Parallel Processing Innovations for GPU Platforms.

In some embodiments, a decoder operates on GPU-platform or combinedCPU-GPU platform. Various decoding processes are mapped to the GPU,including inverse transform, inverse quantization, motion compensation,intra prediction, deblocking, and film grain noise addition.

In general, a given decoding process can be mapped onto the GPUaccording to the following guidelines. The smallest unit (or quantum) ofwork for the decoding process is defined. The quantum does not depend onother quanta. Having small independent units for the quanta helpsincrease parallel processing in the GPU.

The inputs to the quantum for the decoding process are then defined. Theinputs can include data streams, images and/or constants. In manyimplementations, defining inputs as sequential reads improvesperformance. The outputs of the quantum are also defined. In someimplementations, the outputs are limited to four separate buffers, anddefining outputs as sequential writes improves performance (even morethan sequential reads).

Then, an optimal balance between register usage, memory access patterns,and the number of passes through the data is found for the decodingprocess, depending on target architecture and/or expected usagepatterns. For example, an ideal shader program is configured to haveminimal register usage, minimal passes through the data, and sequentialmemory access patterns in both input and output. In practice, one ormore of such constraints may be loosened. Where available, native SIMDoperations can be used to improve performance. Branches (such asconditional logic) can be replaced with other logic (such as tablelookups) to improve performance.

Finally, if data processed in the decoding process have datadependencies, a wave approach can be applied to increase parallelism inprocessing with the GPU. The wave approach can be static or dynamic.

In particular, the decoder uses one or more of the following innovationsto enhance GPU decoding.

1. inverse transform implementations adapted for GPU platforms;

2. inverse quantization implementations adapted for GPU platforms;

3. fractional interpolation innovations for GPU platforms;

4. intra prediction using waves for GPU platforms;

5. loop filtering using waves for GPU platforms;

6. memory usage innovations for GPU platforms;

7. film grain noise generation innovations for GPU platforms;

8. asynchronous decoding by the GPU and CPU(s);

9. a GPU command buffer filled by CPU(s) and emptied by the GPU; and

10. a synchronization interface between the GPU and CPU(s).

The intra prediction and loop filtering innovations (using waves)address dependencies that complicate parallel decoding with a GPU. Theother innovations address memory consumption and other resource issues.In one H.264 implementation, the GPU innovations collectively facilitatereal-time H.264 decoding of high-definition content with a software-onlydecoder. Before describing these innovations, however, example GPUarchitectures and CPU/GPU interfaces are described.

A. Example Architectures for GPU-platform Decoding.

In some embodiments, the decoder operates in conjunction with a graphicsprocessing unit in an architecture such as described herein. Forpurposes of video decoding, the graphics processing unit is in somerespects used as a general purpose unit. FIGS. 40 and 41, and theaccompanying description, illustrate features of example GPUarchitectures. Alternatively, a decoder runs on a GPU architecturehaving other and/or addition features.

FIG. 40 shows an example high-level GPU architecture (4000) used in someembodiments. To map a decoding process (such as an inverse transform orloop filtering) to the GPU architecture (4000) involves several steps.The GPU architecture (4000) was designed for use by graphics programmersto create real-time 2D and 3D graphics, not for real-time videodecoding. A preliminary step in mapping video decoding processes to theGPU architecture (4000) is to understand how GPU terms (e.g., shader,primitive, stream, texture) relate to terms conventionally used todescribe parts of the video decoding processes.

The details of the GPU architecture (4000) vary depending onimplementation. For example, different implementations have differentnumbers of arithmetic logic units (“ALUs”), different numbers ofregisters, different instructions, different cycle timing and/ordifferent memory configurations.

The GPU architecture (4000) includes a shader processor with vertexfetch registers and ALUs shared between the vertex processor (4010) andpixel processor (4030). The vertex fetch registers can be converted totexture fetch registers. Each of the ALUs is capable of running xidentical instructions (from x contexts executing in lockstep) every ycycles.

Conventionally, a “shader” is a graphics program that runs on the shaderprocessor. For video decoding, a shader is a simple program that runs oneither the vertex processor (4010) or pixel processor (4030). Shaderprogramming is done, for example, using a high-level shader language ormicrocode assembly language.

A “primitive” is a single set of data for a decoding pipeline. Thepipeline is, for example, one vertex shader plus one pixel shader, plusstate for the shader units, primitive assembly, and blend unit, etc.Even when a primitive includes two shaders, the shader for the pixelprocessor (4030) can be a dummy no-op shader when only the vertexprocessor (4010) is used.

In the GPU architecture (4000), a shader reads its input directly frommain memory through a set of streams or textures. A pixel shader canalso read data from the outputs of a primitive assembly module (4020). Ashader can accept as input various combinations of streams and textures.In general, streams are useful for reading arrays of data structures,where a given data structure can consist of heterogeneous data types. Onthe other hand, textures are useful for reading 1D, 2D or 3D images, orarrays (sometimes termed stacks) of 2D images, or cubic images, where animage consists of homogeneous data types.

A shader can write its results directly to main memory using a memoryexport command. The memory export function allows the shader to writefinal or partial results to main memory (4060) without going through themore expensive dynamic memory (4050) to the main memory (4060).

The vertex processor (4010) and pixel processor (4030), for practicalpurposes, can be treated as a series of highly parallel execution units.Two features of the architecture (4000) facilitate parallelism. First,the shared ALUs can operate as parallel execution units because of adeep pipeline and multithreading capability in each of the vectorprocessor (4010) and pixel processor (4030). The pipeline caneffectively convert the ALUs, with many execution units each, to behavelike ALUs with even more execution units each. The multithreadingcapability allows resources freed up by one primitive to be used by thenext primitive, which helps to hide memory latency from reads andwrites. Second, each of the execution units is capable of executingSIMD-like instructions. Given this potential for parallel processingacross execution units, the GPU runs efficiently when each primitiveruns the same shader on hundreds, or even thousands, of pieces of datasimultaneously. When this parallel processing capacity is coupled withhigh memory bandwidth, a single GPU completes some tasks quicker thanthree CPU cores working in unison on the same tasks.

FIG. 41 shows an example shader functional model (4100) used in someembodiments. The details of the shader model (4100) vary depending onimplementation. For example, different implementations have differentnumbers of registers, different native operations and/or different cycletiming.

The shader functional model (4100) applies for either a vertex processor(4010) or a pixel processor (4030). The vertex processor (4010) andpixel processor (4030) can be implemented separately. Or, they can sharehardware that is reconfigured by the GPU on the fly to perform vertexprocessing or pixel processing, in which case fetch units and ALUs areshared by the processors (4010, 4030) and dynamically allocated based oncurrent workload. The main differences between the processors (4010,4030) relate to how they input and output data. In exampleimplementations, decoding processes are mapped to a vertex shader(running on the vertex processor (4010)) to take advantage of how thevertex processor (4010) handles input. A vertex shader can be programmedusing a high-level shader language or microcode assembly language.

Calculations in an example shader use floating-point representation andfloating-point arithmetic. Typical video decoding processes (e.g.,inverse transform or motion compensation as in the H.264 standard) callfor pixel manipulation and integer operations, however. A set of integerfunctions (macros) facilitate pixel manipulation for the video decodingprocesses.

In addition, the example shader use registers. All shaders in a shaderunit (ALU) share these registers, however; as more registers are used torun a single shader, fewer shaders in the unit run in parallel.

The example shader also supports static and dynamic branches, functions,and loops. Dynamic predication, branches, and loops are very costly,however. For example, in some cases, a shader will take both branches ofan “if-else” statement, thereby doubling the workload of the shader.Dynamic predication, branches and loop are thus replaced in many cases,for example, with table lookups.

Finally, one pair of vector and scalar instructions is executed percycle. The number of instruction pairs in a shader is limited in someimplementations. Complex functions such as deblocking can be written asseveral “smaller” shaders (e.g., CalcBoundaryStrength,DeblockVerticalEdges, DeblockHorizontalEdges, etc.) to fit in programmemory or, as is more often the case, for performance reasons. Forexample, a long process can be split into sub-processes that areparallelizable.

The example shader can use a table of constants. This is particularlyuseful for static tables such as user-defined scaling lists used ininverse quantization. Finally, a vertex shader has pointers to streamsand/or textures.

A vertex shader reads from memory (4060) using a stream and/or texture.Streams and textures flexibly support a variety of formats (e.g., float,integer, short, sign, scaled, etc.). In particular, streams are usefulfor reading arrays of data structures in which each data structure mayhold heterogeneous elements. For example, a shader can stream inmacroblock data, where each macroblock element consists of a mixture ofunsigned chars and shorts for the parameters mb_type, mb_field, cbp,etc. Textures, on the other hand, are useful for reading arrays ofhomogeneous data, such as arrays of unsigned chars. For example, ashader reads pixel data, such as references images from the decodedpicture buffer, as texture.

A texture is specified by a texture sampler (3 pointers). Texturessupport wrapping, clamping, and mirroring at the hardware level.Automatic clamping can be used to handle unrestricted motion vectors inmotion compensation. If an unrestricted motion vector points to a regionoutside the bounds of the reference picture, the texture canautomatically clamp the return results without the need to pad thereference picture. Textures also automatically support bilinear andanisotropic filtering. Bilinear filtering can be used for fast ½-pel and¼-pel interpolation in motion compensation. A cache supports reads fromtextures and is optimized for localized random access reads.

The example vertex shader can directly write to main memory (4060) usinga specialized function, MemExport. Writes using MemExport are especiallyeffective if done sequentially. MemExport writes directly to main memory(4060) and does not automatically maintain cache coherency between theGPU read cache and CPU caches. It is up to the programmer to maintainthis cache coherency, using flush and store commands for the CPU cachesand invalidate commands for the GPU caches.

As for shader hardware implementation, an example shader processorcontains vertex fetch units and ALUs shared between the vertex and pixelprocessors (4010, 4030). The ALUs are also known as shader units, andeach contains execution units. The shader units run in parallel to eachother. Within a given shader unit, x simultaneous threads run inlockstep, even if not used. Execution units are fully independent and donot use feedback from other execution units. For branches and loops, thethreads typically execute all the branches and loop iterations to finishall of them. It is efficient if all threads follow the same path(branches can skip quickly).

In many decoding processes, one tradeoff is to use simpler shaders thatuse fewer registers but make more passes through the input data. Forexample, a shader for ½-pel and ¼-pel interpolation in motioncompensation can be implemented using large tables to hold 2D filtervalues, running a 2D convolution on input pixel data in a single passbut using lots of registers to hold the input data and the 2D filtervalues. Alternatively, the shader uses multiple passes for motioncompensation and breaks the interpolation into several dependent passes,one for ¼-pel interpolation and another one for ¼-pel interpolation.This illustrates the tradeoff between register usage (parallelism) andmulti-pass processing (multiple reads/writes). As a general rule, aslong as the number of passes is small, gains in parallelism trump thegreater number of dependent read/writes, and the shader will run fasteron the GPU.

B. Example GPU Interfaces for GPU-Platform Decoding.

In some embodiments, a CPU and GPU coordinate across a communicationsinterface to decode video. Performance improves when decoding work iseffectively partitioned between CPU core processors and the GPU, withCPU processes and GPU processes running asynchronously.

In an example implementation, decoding tasks are partitioned such thatthreads on CPU cores perform entropy decoding, and the GPU performsremaining decoding tasks such as inverse transform, inversequantization, motion compensation, intra prediction, deblocking, andfilm grain noise addition. Entropy decoding, especially CABAC decoding,is serial in nature, involving decisions and tables updated on abit-by-bit basis. A CPU that contains a built-in branch predictor andcan handle read-modify-write operations on main memory millions of timesper second is well suited for this serial processing. On the other hand,the GPU is well suited for inverse transform operations that can beeasily parallelized over an entire image of transform coefficients(e.g., since each 4×4 (or 8×8) inverse transform is independent to eachother). The GPU can efficiently operate on multiple 4×4 (or 8×8) blocksof data simultaneously.

In some implementations, the GPU is a FIFO device. The CPU generatestasks (corresponding to primitives for the GPU) and inserts them in aFIFO command buffer queue. The GPU extracts primitives from the commandbuffer, one at a time, and executes them in serial order. The CPU andGPU maintain synchronization, for example, using “fences.” A fence is amarker inserted into the command buffer by the CPU. The fence istriggered once the GPU reaches it. Synchronization helps the CPU trackwhen a picture has been completely processed by the GPU in order toreuse resources (e.g., PicHolder structures) and output the picture,subject to display ordering constraints. When a fence is signaled, thepicture has been completely decoded. The fence is inserted after thelast video decode algorithm, e.g., film grain noise addition. Thepicture is then copied into an output buffer and marked as available forreference in the decoded picture buffer.

In some implementations, the GPU is limited in how it uses memory. TheGPU cannot do read-modify-write operations on main memory or read frommemory a value that has been written by the same primitive. Working datais stored in the registers of each execution unit, and there are nottransfers of data between the execution units. When reading from memory,the GPU has two small caches. Reading contiguous chunks of memory makeeffective use of the caches. The GPU reads directly from main RAM,bypassing CPU caches. When writing to memory, the GPU uses awrite-combine strategy, bypassing the GPU read caches and the CPUcaches. When implementing an algorithm for the GPU, care is taken tounderstand what memory is resident in which cache and act accordingly(flush or store) to avoid data corruption.

C. Inverse Transform Innovations for GPU-Platform Decoding.

In some embodiments, a decoder uses inverse transform operations mappedto a GPU platform. For example, integer transforms according to theH.264 standard are mapped to a GPU that natively supports floating pointoperations and matrix operations. The H.264 standard specifies two typesof transforms, a 4×4 transform used in luma 4×4 and chroma_4×4 modes andan 8×8 transform used in luma_8×8 mode. Features of the exampleH.264-GPU mapping include:

-   -   1. classifying the transform coefficients into three types:        luma_4×4, chroma_4×4 and luma8×8;    -   2. defining the GPU quantum of work for luma_4×4 blocks as four        4×4 sub-blocks of transform coefficients;    -   3. defining the GPU quantum of work for luma_8×8 blocks as one        8×8 sub-block of transform coefficients;    -   4. defining the quantum of work for chroma_4×4 as two 4×4        sub-blocks of transform coefficients; and    -   5. using native matrix multiplication and matrix addition to        calculate inverse transform.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures. For another type of transform or other type of GPU, themapping can include more or fewer types, different types, differentquanta of work, and/or different operations.

1. Example H.264-GPU Mapping.

FIG. 42 shows an example framework (4200) with separate processing pathsfor inverse transform types according to the H.264 standard. In theframework (4200), a decoder classifies transform coefficients for apicture into three types for the GPU. In particular, a classifier module(4210) classifies transform coefficients for the picture into luma 4×4,chroma 4×4, and luma 8×8 types.

The decoder then performs a three-pass inverse transform with the GPU,one pass for each transform coefficient type. The order of the threepasses depends on implementation. Different shaders can implement theinverse transforms for the different passes.

In the luma 4×4 pass, the decoder performs a fast 4×4 inverse transform(4220) on the luma 4×4 blocks in a picture. For example, the decoderuses a 4×4 inverse transform implementation as shown in FIG. 45 anddescribed below. Alternatively, the decoder uses another inversetransform implementation. For the luma 4×4 pass, the quantum of work isfour 4×4 blocks of transform coefficients.

In the chroma 4×4 pass, the decoder performs a fast 4×4 inversetransform (4220) on the chroma 4×4 blocks in a picture. For the chroma4×4 pass, the quantum of work is two 4×4 blocks at a time, one from theU channel and one from the V channel.

In the luma 8×4 pass, the decoder performs a fast 8×8 inverse transform(4230) on the luma 8×8 blocks in a picture. For example, the decoderuses an inverse transform implementation with matrix multiplications andmatrix additions. Alternatively, the decoder uses another inversetransform implementation. For the luma 8×8 pass, the quantum of work isone 8×8 sub-block of transform coefficients.

Alternatively, instead of classifying transform coefficients for apicture and performing multiple passes across the picture, the decoderoperates on a slice-by-slice or other basis.

2. Multi-Pass Inverse Transforms with GPU.

FIG. 43 shows a generalized technique (4300) for performing inversetransforms in multiple passes with a GPU. A decoder such as the onedescribed above with reference to FIG. 2 or other decoder performs thetechnique (4300).

The decoder receives transform coefficients from video (e.g., frominverse quantization) and classifies (4310) the transform coefficientsinto multiple types. For example, an H.264 decoder classifies thecoefficients into luma 4×4, chroma 4×4 and luma 8×8 types. Alternatively(e.g., for a different standard), the decoder classifies the transformcoefficients into other and/or additional types.

The decoder (with a GPU) then performs (4320) inverse transforms on thetransform coefficients in one of multiple passes that correspond to themultiple types, respectively. Each of the multiple types has a quantumof work associated with it. Example quanta for an H.264-GPU mapping aredescribed above. Alternatively (e.g., for a different type of GPU), thequanta are different to more efficiently use a different number ofregisters. For a different transform and/or GPU, the quanta are definedto be small independent units that increase parallelism on thearchitecture. The decoder determines (4330) whether to continue withanother pass and, if so, performs (4320) the next inverse transformpass.

3. Example GPU Implementation of 4×4 Transform.

In some implementations, a GPU uses an implementation of 4×4 inversetransform as follows for luma 4×4 blocks. The decoder (with the GPU)partitions a picture into 16×16 macroblocks and partitions themacroblocks into 4×4 blocks. For the inverse transform, each of the 4×4blocks is independent of the other 4×4 blocks, and the GPU can performthe inverse transforms for different blocks in parallel.

FIG. 44 shows the input 4×4 block order (4410) and the output 4×4 blockorder (4420) in the example implementation. The luma 4×4 inversetransform shader fetches four sub-blocks at a time. As shown in FIG. 44,the shader fetches 64 non-contiguous signed shorts from a 2D texture oftransform coefficients (e.g., fetching blocks 0 . . . 3 in column order,or fetching blocks 4 . . . 7 in column order). This involves fetchingfour contiguous values from the 2D texture, skipping 12 values, fetchingfour more, and so on. Although the shader could fetch more blocks at atime (e.g., an entire macroblock with blocks 0 . . . 15), this wouldincrease register usage for the input data and hurt parallelism.

The shader then performs an inverse transform, scaling, and transpose oneach block. The GPU shaders natively support 4×4 matrixes and fast 4×4matrix operations such as addition, multiplication, and transposition.As such, the 4×4 fast inverse transform mode is implemented in terms of4×4 matrix multiplications and additions. FIG. 45 shows pseudocode(4500) for example bit-exact matrix equations for the 4×4 inversetransform mode.

To start, the input matrix A is multiplied by the transform matrix Tusing a native matrix multiplication, and the result is stored in theintermediate matrix M0. Rows 2 and 3 of the intermediate matrix M0 areadjusted by a constant matrix factor [1, 1, 1, 1] before scaling theresults by a factor of ½ and flooring the scaled values. Thisessentially results in integer values in the intermediate matrix M1.

Next, the decoder multiplies a transpose of intermediate matrix M1 withthe matrix T using a native matrix multiplication, and the result isstored in the intermediate matrix M2. The transpose operation completesthe pre- and post-multiplication of the input data with the 4×4transform basis vectors. Rows 2 and 3 of M2 are adjusted by the constantmatrix factor before scaling by a factor of ½ and flooring the final 4×4results, which are put in the output matrix B.

As shown in FIG. 44, the decoder exports output data as 64 contiguoussigned shorts (e.g., blocks 0 . . . 3 in row order). Either the inputreads or output writes can be sequential. For the architecture of theGPU in the example implementation, making the writes sequential hasgreater performance benefits than making the reads sequential.

The GPU uses an analogous inverse transform implementation for 4×4chroma blocks, with a smaller input quantum but correspondingly higherparallelism. The GPU uses native matrix multiplication operations andnative matrix addition operations for 4×4 chroma blocks and for luma 8×8blocks.

D. Inverse Quantization Innovations for GPU-Platform Decoding.

In some embodiments, a decoder uses inverse quantization operationsmapped to a GPU platform. For example, inverse quantization operationsaccording to the H.264 standard are mapped to a GPU with constantregisters that can hold user-defined scaling lists. Features of theexample H.264-GPU mapping include:

-   -   1. classifying inverse quantizations into five types: luma_DC,        chroma_DC, luma_4×4, luma_8×8, and chroma_4×4;    -   2. defining the GPU quantum of work for the luma_DC type as one        4×4 block of DC coefficients;    -   3. defining the GPU quantum of work for chroma_DC type as one        2×2 block of DC coefficients;    -   4. defining the GPU quantum of work for luma_4×4 type as one        1×16 row of AC coefficients;    -   5. defining the GPU quantum of work for luma_8×8 type as one        4×16 block of AC coefficients;    -   6. defining the GPU quantum of work for chroma_4×4 type as two        2×4 blocks of AC coefficients (one from U, one from V); and    -   7. using constant registers to hold user-defined scaling lists        and normalization adjustment matrix.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures. For another type of quantization operation or other type ofGPU, the mapping can include more or fewer types, different types,different quanta of work, and/or different operations.

1. Example H.264-GPU Mapping.

In the example H.264-GPU mapping, a decoder performs inversequantization in a framework with separate processing paths for differentinverse quantization types according to the H.264 standard. In theframework, a decoder classifies inverse quantization operations for apicture into five types for the GPU. In particular, a classifier moduleclassifies inverse quantization operations for the picture into luma DCcoefficient, chroma DC coefficient, luma 4×4 block AC coefficient, luma8×8 block, and chroma 4×4 block AC coefficients types.

The decoder then performs five-pass inverse quantization with the GPU,one pass for each inverse quantization operations type. The order of thefive passes depends on implementation. Different shaders can implementthe inverse quantization for the different passes.

In each of the respective passes, the decoder implements the inversequantization operations generally as specified in the H.264 standard,potentially using floating point operations and matrix operations inplaces to expedite processing with the GPU.

In some GPU implementations, the decoder uses a set of constantregisters to hold a scaling list and/or normalization adjustment matrixfor inverse quantization operations. The H.264 standard (and some otherstandards) allow a user to define perceptual weights for transformcoefficients. The scaling list is, for example, a user-definedperceptual quantization matrix signaled in a picture header. Or, thescaling list is a default scaling list having default perceptualweights. In some GPU implementations, the set of constant registers isan array of 256 4D registers.

The quanta of work for the respective inverse quantization typesfacilitate parallel processing in each of the respective passes. Thus,in the luma DC pass, the GPU performs inverse quantization in parallelon different 4×4 blocks of DC coefficients. In the chroma DC pass, theGPU performs inverse quantization in parallel on different 2×2 blocks ofDC coefficients. The GPU similarly performs inverse quantization inparallel on multiple blocks of AC coefficients (having the definedquantum size) within the luma 4×4 pass, luma 8×8 pass or chroma 4×4pass.

Alternatively, instead of classifying inverse quantization operationsfor a picture and performing multiple passes across the picture, thedecoder operates on a slice-by-slice or other basis.

2. Multi-Pass Inverse Quantization with GPU.

FIG. 46 shows a generalized technique (4600) for performing inversequantization in multiple passes with a GPU. A decoder such as the onedescribed above with reference to FIG. 2 or other decoder performs thetechnique (4600).

The decoder receives transform coefficients from video (e.g., from anentropy decoding task) and classifies (4610) inverse quantizationoperations for the transform coefficients into multiple types. Forexample, an H.264 decoder classifies the inverse quantization operationsinto luma DC, chroma DC, luma 4×4 AC, luma 8×8, and chroma 4×4 AC types.Alternatively (e.g., for a different standard), the decoder classifiesthe inverse quantization operations into other and/or additional types.

The decoder (with a GPU) then performs (4620) inverse quantization onthe transform coefficients in one of multiple passes that correspond tothe multiple types, respectively. Each of the multiple types has aquantum of work associated with it. Example quanta for an H.264-GPUmapping are described above. Alternatively (e.g., for a different typeof GPU), the quanta are different to more efficiently use a differentnumber of registers. For a different inverse quantization operationand/or GPU, the quanta are defined to be small independent units thatincrease parallelism on the architecture. The decoder determines (4630)whether to continue with another pass and, if so, performs (4620) thenext inverse quantization pass.

E. Fractional Interpolation Innovations for GPU-Platform Decoding.

In some embodiments, a decoder uses motion compensation and fractionalinterpolation operations mapped to a GPU platform. For example,fractional interpolation operations according to the H.264 standard aremapped to multiple passes with a GPU. Features of the example H.264-GPUmapping include:

-   -   1. classifying motion vectors into three types: integer,        center-pel, and off-center pel;    -   2. defining the GPU quantum of work for the motion compensation        shaders for the three types as 8×8 block;    -   3. using a fast off-center pel motion compensation shader that        calculates fractional positions not dependent on a center        location with reduced register usage; and    -   4. using a fast center-pel motion compensation shader that        calculates fractional positions dependent on a center location        fetching a small 9×9 block region.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures. For another type of interpolation operations or other type ofGPU, the mapping can include more or fewer types, different types,different quanta of work, and/or different operations.

1. Example H.264-GPU Mapping.

Motion compensation according to the H.264 standard is computationallycomplex and has high memory access requirements. A 4×4 block can beassigned a unique motion vector that has a horizontal (x) component andvertical (y) component. The two rightmost bits of each motion vectorcomponent indicate the fractional sample position in the referencepicture: the value 0 for the two bits indicates an integer position, thevalue 2 indicates a half-pel position, and the value 1 or 3 indicates aquarter-pel position. The high computational complexity of motioncompensation is due largely to the interpolation used to generate samplevalues at fractional sample positions in reference pictures. Forexample, half-pel offset positions are calculated by convolving thereference picture with a separable, one-dimensional 6-tap filter {1-5 2020-5 1} in the horizontal direction and in the vertical direction.

FIG. 47 shows a chart (4700) indicating integer sample positions andfractional sample positions for interpolation operations according tothe H.264 standard. Integer sample positions are shown in capitalletters, and fractional sample positions are shown in lower-case lettersfor a block in an image plane (e.g., the luma plane). The sample valueat a ½-pel position in one dimension (e.g., b, h, m, s) is computed byapplying the 6-tap filter {1-5 20 20-5 1} to sample values at integerpositions and normalizing the result. The sample value at centerposition j (′/2-pel horizontal offset, ½-pel vertical offset) iscomputed by applying the 6-tap filter {1-5 20 20-5 1} to sample valuesat integer positions to compute sample values at aa, bb, b, s, gg andhh, then applying the 6-tap filter to the un-normalized sample values athalf-pel positions aa, bb, b, s, gg and hh. (Alternatively, the samplevalue at j is computed by applying the 6-tap filter to compute values athalf-pel positions cc, dd, h, m, ee and ff, then applying the filter tothe un-normalized sample values at those half-pel positions.) Values at½-pel offset positions (e.g., positions a, c, d, e, f, g, i, k, n, p, q,and r) are computed by averaging two integer or half-pel position valuesin the vertical, horizontal or diagonal direction.

To complicate matters in H.264, different 8×8 blocks can be assigneddifferent reference picture indices referencing different referencepictures. This can result in high memory access costs and inefficientmemory access patterns when, for example, many different 8×8 blockspoint to many different reference picture in a decoded picture buffer.In a worst case scenario, a motion compensation shader fetches pixeldata from two vastly different positions in memory for each adjacent 8×8block in a series of blocks, with the random memory access patterneffectively thrashing the GPU read cache.

In the example H.264-GPU mapping, the quantum of work for GPU motioncompensation is a single 8×8 block. For motion compensation andfractional interpolation, an 8×8 block is independent from other blocks.An 8×8 block uses one motion vector for each of its four 4×4 blocks (upto four different motion vectors) and uses a single reference pictureindex, regardless of how the block and its containing macroblock areinternally partitioned for motion compensation. The GPU effectivelyperforms parallel processing across different 8×8 blocks in motioncompensation tasks such as fractional interpolation. Alternatively, fora different motion compensation operation, fractional interpolationoperation, and/or GPU, the decoder uses a different quantum of work.

In the example H.264-GPU mapping, the decoder allocates a contiguousimage array to hold the decoded picture buffer. A given motioncompensation shader maps the image array to a 3D texture. Using a 3Dtexture facilitates hardware support for fast random memory accessacross the horizontal (x) and vertical (y) dimensions of a referencepicture image plane, and it also facilitates hardware support for fastrandom memory access to different reference picture image planes alongthe depth (z) dimension of the 3D texture for the decoded picturebuffer. Alternatively, the decoder maps reference pictures to adifferent memory configuration.

FIG. 48 shows an example framework (4800) with separate processing pathsfor motion vector types according to the H.264 standard. In theframework (4800), a decoder classifies blocks in a picture into threemotion vector types for the GPU. In particular, a classifier module(4810) classifies blocks for the picture into integer MV, center-pel MVand off-center-pel MV types. The blocks are, for example, 8×8 blocks,corresponding to the quanta of the different motion vector types.

In some implementations, integer MV block, center-pel MV block, andoff-center-pel MV block types are used as follows. An integer MV blockis an 8×8 block with motion vector(s) (e.g., for the 4×4 blocks) thatreference integer sample positions (e.g., G, H, M and N in FIG. 47). Anoff-center MV block is an 8×8 block with motion vector(s) (e.g., for the4×4 blocks) that reference certain fractional sample positions notdependent on the value at position j. This includes positions a, b, c,d, e, g, h, m, n, p, r, and s. A center MV block is an 8×8 block forremaining cases. For these remaining cases, at least one motion vectorfor an 8×8 block (e.g., internal 4×4 block) references sample values atposition f, i, j, k or q. So, an 8×8 block for which each 4×4 blockpoints to position f, i, j, k, or q is classified as a center MV block.An 8×8 block for which different 4×4 blocks point to a mixture ofinteger positions, center positions (such as j), and off-centerpositions (such as c) is also classified as a center MV block.Alternatively, the MV block types have different definitions.

The decoder then performs three-pass motion compensation with the GPU,one pass for each motion vector type. The order of the three passesdepends on implementation. Different shaders can implement the motioncompensation and fractional interpolation for the different passes.

In the integer MV pass, the decoder (with GPU) performs fast integer pelfetches (4820) from reference pictures in memory. For example, for 4×4blocks of an 8×8 block, the decoder simply fetches sample values from areference picture stored as an image plane in a 3D texture.Alternatively, the decoder uses another implementation.

In the center MV pass, the decoder (with GPU) performs fast center MVmotion compensation (4830). For example, the decoder uses a fast centerMV vertex shader as described below. Alternatively, the decoder usesanother shader for center MV motion compensation.

In the off-center MV pass, the decoder (with GPU) performs fastoff-center MV motion compensation (4840). For example, the decoder usesa fast off-center MV vertex shader as described below. Alternatively,the decoder uses another shader for off-center MV motion compensation.

Alternatively, instead of classifying blocks for a picture andperforming multiple passes across the picture, the decoder operates on aslice-by-slice or other basis.

Tests involving the sample video sequences Yozakura, Tallships andChoochoo illustrate benefits of a multi-pass approach that separatestypes of fractional sample interpolation. Yozakura is a high-definitionH.264 MBAFF bit stream that is difficult to decode in real-time on manyhardware architectures. The number of ½-pel and ¼-pel motion vectorsdecoded per frame for Yozakura is much higher than Tallships andChoochoo. One reason Yozakura is tough to decode is the large number ofinterpolation operations needed for motion compensation per frame. Fortypical frames, Yozakura uses twice as many interpolation operations perframe than Tallships, and it uses 3 times as many interpolationoperations per frame as Choochoo. Not all interpolation operations arethe same in complexity for the GPU, however. In particular, off-centerpel interpolation can be performed much faster than center-pelinterpolation, which illustrates a benefit of separating these two typesof operations.

2. Multi-pass Motion Compensation/Fractional Interpolation with GPU.

FIG. 49 shows a generalized technique (4900) for performing motioncompensation/fractional interpolation in multiple passes with a GPU. Adecoder such as the one described above with reference to FIG. 2 orother decoder performs the technique (4900).

The decoder receives motion vectors for blocks and classifies (4910) theblocks into multiple motion vector types. For example, an H.264 decoderclassifies the blocks into integer MV, center-pel MV and off-center-pelMV types. Alternatively (e.g., for interpolation according to adifferent standard), the decoder classifies the blocks into other and/oradditional motion vector types.

The decoder (with a GPU) then performs (4920) motion compensation forthe blocks in one of multiple passes that correspond to the multiplemotion vector types, respectively. Each of the multiple motion vectortypes has a quantum of work associated with it. Example quanta for anH.264-GPU mapping are described above. Alternatively (e.g., for adifferent type of GPU), the quanta are different to more efficiently usea different number of registers. For a different interpolation and/orGPU, the quanta are defined to be small independent units that increaseparallelism on the architecture. The decoder determines (4930) whetherto continue with another pass and, if so, performs (4920) the nextmotion compensation pass.

In some implementations, the decoder runs a GPU shader for integer MVblocks, using reference picture indices to identify image planes in a 3Dtexture for the decoded picture buffer, fetching sample values astexture fetch operations, and returning results in arrays of predictedblocks. The GPU shader for integer MVs is fast, not performing sampleinterpolation. The decoder then runs a GPU shader that implements motioncompensation and fractional interpolation for center MV blocks,returning results in arrays of predicted blocks. Finally, the decoderruns a GPU shader that implements motion compensation and fractionalinterpolation for off-center MV blocks, returning results in arrays ofpredicted blocks.

3. Example GPU Implementation of Fractional Interpolation and MotionCompensation.

In some implementations, a GPU uses a specialized vertex shader routinefor off-center MV motion compensation/fractional interpolation and usesa specialized vertex shader routine for center MV motioncompensation/fractional interpolation.

An example vertex shader for center MV motion compensation performsmotion compensation and fractional interpolation on a block-by-blockbasis for multiple 4×4 blocks in parallel. For a given 4×4 block, theshader uses a 9×9 block of sample values to have the support forfiltering with the 6-tap filter. The 9×9 block includes the 4×4 blockstarting on the third row down, third column from the left, to supportthe 6-tap filter at the 16 j positions throughout the 4×4 block. Theshader loads the 9×9 block of sample values as needed.

In terms of FIG. 47, when computing a sample value at position j (orposition f, i, k or q, which depends on the value at j), the shadercomputes sample values at positions aa, bb, b, s, gg and hh (or cc, dd,h, m, ee and ff) in a first stage, then computes the value for positionj using un-normalized first stage values. The shader can storeintermediate, first stage values (e.g., un-normalized, intermediate½-pel offset values) to use in other interpolation operations.

An example vertex shader for off-center MV motion compensation performsmotion compensation and fractional interpolation on a block-by-blockbasis for multiple 4×4 blocks in parallel. For a given 4×4 block, theshader uses 78 input samples and does not buffer intermediate results.

Generally, reference pictures are stored in an array of buffers indexedin memory. When a decoder adds or deletes a reference image, the data inthe buffer changes. When the decoder performs other DPB managementtasks, it reorders pointers to the buffers. The example shaders organizereference pictures as image planes in a 3D texture and access thereference picture data using texture fetch operations.

In some implementations, the decoder (with GPU) tiles data for 4×4blocks. In motion compensation, the decoder computes sample values for4×4 blocks in memory, not rows of sample values. Tiling of 4×4 blocks inintermediate processing can help improve cache locality. Reference fielddata can be kept in an interleaved manner in a single frame buffer, orreference fields can be buffered separately from corresponding referenceframes.

F. Intra Prediction Innovations Using Waves for GPU-Platform Decoding.

In some embodiments, a decoder uses intra prediction operations mappedto a GPU platform. For example, the decoder organizes intra blocks asdynamic waves and performs intra prediction on a wave-by-wave basis.Features of the example H.264-GPU mapping include:

-   -   1. building dynamic waves based on the intra prediction patterns        in a picture;    -   2. merging luma and chroma waves to increase parallelism in each        wave for the GPU; and    -   3. reducing shader branches for various prediction directions        using table based lookup.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures.

In general, the term intra prediction refers a spatial prediction modein which redundancy between adjacent blocks of the same picture isexploited. The H.264 standard specifies four different intra macroblocktypes: I_4×4, I_8×8, I_16×16 and I_PCM. For the I_PCM macroblock type,raw Y, U and V values are coded into the bit stream. Intra “prediction”is simply a copy operation handled before other intra prediction steps.For the other intra macroblock types, predicted sample values arecalculated for a 4×4 block (for I_4×4 type), 8×8 block (for I_8×8 type)or 16×16 block (for I_16×16 type) using a set of pixel values from theleft macroblock, above-left macroblock, above macroblock and/orabove-right macroblock. These dependencies reduce the number ofprimitives (separate sets of data) that a GPU shader can execute inparallel within a wave for intra prediction.

More specifically, the intra prediction modes used to predict samplevalues create dependencies between the sample values of a current blockand the sample values of one or more neighbors. An intra macroblock typehas a number of available prediction modes, which typically correspondto different directions of extrapolation from the neighboring samplevalues into the current block. In the H.264 standard, there are nineprediction modes for I_4×4, nine prediction modes for I 8×8, and fourprediction modes for I 16×16.

The logic specified in the H.264 standard for calculating spatialpredictions in the various modes includes numerous formulas typicallyhandled by branches or indirect calls in a CPU architecture. A directmapping of the CPU approach to the example GPU architecture could resultin execution of all of the branches for many blocks, which is veryinefficient.

For the H.264-GPU mapping, one goal is increase parallelism (e.g., moreprimitives per shader and fewer shaders) in execution of shaders for theintra prediction. Another goal is to reduce wasted computations.

1. Using Waves for Intra Prediction.

In some embodiments, the decoder (with GPU) uses waves to efficientlyperform intra prediction on a GPU architecture. Basically, the GPU usesdifferent execution units to process different intra blocks within awave in parallel. Effectively organizing waves helps the decoder reducethe number of waves while simultaneously increasing per waveparallelism.

FIG. 50 shows a technique (5000) for performing intra prediction usingwaves. A decoder such as the one described above with reference to FIG.2 or other decoder performs the technique (5000).

To start, the decoder organizes (5010) intra blocks as waves. A waveincludes one or more of the intra blocks. For example, the decoderorganizes 4×4, 8×8, and 16×16 intra blocks as waves. Alternatively, thedecoder organizes blocks of other and/or additional sizes.

In some embodiments, the decoder organizes the blocks as static wavesbased on how the blocks are laid out with respect to each other. Suchstatic waves are laid out the same in different pictures, regardless ofdifferent slice or macroblock patterns in the different pictures. Ingeneral, a static wave is based on theoretical possibilities withoutconsidering actual data such as macroblock type and intra predictionmode. For example, the static waves roughly correspond to diagonal linesof blocks, starting from the top left corner and rippling toward thebottom right corner. The lines are tilted to the right because theneighboring sample values that can potentially be considered in spatialprediction for a current block are in blocks to the left of, above-leftof, above, and above-right the current block.

While using static waves increases parallelism in some scenarios, thestatic waves may assume dependencies that do not actually exist betweenthe blocks. Rather than assume a set of dependencies applies for a givenblock, the decoder can instead determine which dependencies actually arepresent between blocks. For example, if the context neighbors of acurrent intra block are in a different slice or are inter predicted, insome implementations, the current intra block does not use intraprediction from them, and intra prediction dependencies can be removed.

Aside from considering macroblock types and slice patterns, in someimplementations the decoder also considers spatial prediction modes.Different spatial prediction modes have different dependencies, roughlycorresponding to different directions of spatial extrapolation. Forexample, for many spatial prediction modes, a current block has nodependencies on the block to its above-right.

Often, organizing intra blocks as static waves results in too manywaves. This can hurt performance due to switching overhead fromwave-to-wave. Considering actual dependencies can help the decodercombine waves, making fewer waves that are typically bigger andtherefore provide more opportunities for parallel processing.

So, in some embodiments, the decoder organizes the blocks as dynamicwaves based on analysis of dependencies within the blocks. For example,the decoder organizes blocks as described in the following section.Alternatively, the decoder organizes blocks as dynamic waves usinganother approach.

In particular, in B slices and P slices, intra blocks are typically fewin number and sparse. There are typically not many dependencies forintra blocks in B and P slices. Organizing intra blocks as dynamic waves(considering macroblock type to identify isolated intra blocks with nointra dependencies) can help process separate intra blocks in parallelwithin one wave for Band P pictures. For example, if a B slice includessix isolated I_16×16 macroblocks that share no edges, the sixmacroblocks are intra predicted in parallel in one wave.

For I slices, I_PCM macroblocks provide similar opportunities forremoving intra prediction dependencies. I_PCM macroblocks are uncommonin many coding scenarios, however. Or, if the decoder considers actualprediction modes, organizing blocks as dynamic waves can help thedecoder eliminate assumed spatial prediction mode dependencies that arenot in fact present, which helps increase parallelism.

Returning to FIG. 50, after organizing (5010) blocks as waves, thedecoder performs intra prediction on a wave-by-wave basis. The decoderperforms (5020) intra prediction for a wave and determines (5030)whether to continue with another wave. If so, the decoder performs(5020) intra prediction for the next wave.

For example, the decoder performs intra prediction for wave 0, whichincludes the top-left intra block in a picture and any other intra blockthat has no intra prediction dependencies on another intra block. Insome implementations, in a B picture or P picture, isolated intra blocksall over the picture can be processed as part of the first wave, sincethey have no intra prediction dependencies. The decoder then performsintra prediction for wave 1, which includes intra blocks that only haveintra prediction dependencies on intra blocks in wave 0. Then, thedecoder performs intra prediction for wave 2, which includes intrablocks that have intra prediction dependencies on intra blocks in waves0 and 1. The decoder thus continues wave-by-wave through the picture.

Alternatively, instead of organizing intra blocks for a picture andperforming wave-by-wave intra prediction across the picture, the decoderoperates on a slice-by-slice or other basis.

2. Dynamic Waves for Intra Prediction.

In some embodiments, the decoder (with GPU) organizes intra blocks asdynamic waves for intra prediction. Building dynamic waves for pictureshelps improve performance by reducing the number of waves and,correspondingly, increasing the number of intra blocks in the remainingwaves. In particular, building dynamic waves improves performance for Band P slices because non-intra coded macroblocks in them provide waveboost, tending to cause intra blocks to be processed in earlier waves.

FIG. 51 shows an example technique (5100) for organizing intra blocks ofa picture in dynamic waves. A decoder such as the one described abovewith reference to FIG. 2 or other decoder performs the technique (5100).

Initially, the decoder assigns a wave number of zero to the intra blocksin the picture. For a current block, the decoder identifies (5110) intraprediction dependencies for the block. For example, the decoder scansthe image in macroblock/block order as in the H.264 standard.

The decoder identifies (5120) wave number(s) of neighbor block(s) uponwhich the current block has dependencies and assigns (5130) a wavenumber to the current block. For example, the decoder assigns wavenumber max(DEPBLK)+1 to the current block. In an H.264 decoder, DEPBLKrepresents wave number(s) for a set of one or more blocks whose membersdepend on macroblock type (intra or inter), prediction mode, frame typeand MBAFF macroblock flags. More generally, DEPBLK indicates wavenumbers for blocks upon which the current block depends for intraprediction. In some implementations, DEPBLK is implemented as a table ofoffsets subtracted from the position of the current block to determinepositions (and then wave numbers) of adjacent blocks. The decoderdetermines (5140) whether to continue with another intra block in thepicture and, if so, identifies (5110) intra prediction dependencies forthe next intra block.

In some implementations, the block size for wave building is 8×8.Setting a block size sets a tradeoff between the number of waves andshader size. Setting block size to 4×4 typically doubles the number ofwaves but requires more memory; wave building is more computationallyintensive but still linear in complexity.

In some implementations, the decoder increments a counter for number ofblocks of different types within the respective waves. For example, whena block is assigned a wave number, a counter for that type of block(based on the type of the macroblock including the block) in that waveis incremented. Using the counters helps the decoder manage intraprediction computations more efficiently.

Finally, to speed up the wave building process in some implementations,the decoder performs the wave building on a slice-by-slice basis fromthe bottom up in a multi-slice picture. The last slice is processedfirst and scanned according to macroblock/block order within the slice.This makes the unavailability of neighboring macroblocks from differentslices (for purposes of intra prediction) implicit.

3. Tracking Wave Organization.

In some embodiments, the decoder (with GPU) tracks organization of intrablocks as waves using a data structure such as the structure (5200)shown in FIG. 52. Alternatively, the decoder tracks organization ofintra blocks as waves using another data structure.

The structure (5200) is organized wave-by-wave. The structure (5200)starts with a section for wave 0, followed by a section for wave 1, andso on. The section for a wave includes one or more sections fordifferent block sizes for blocks in the wave. For example, the sectionfor wave 0 includes an intra 4×4 section, an intra 8×8 section, and anintra 16×16 section. The intra 4×4 section includes indices of 4×4 intrablocks in wave 0, the intra 8×8 section includes indices of 8×8 intrablocks of that size in wave 0, and so on. The decoder uses raster scannumbering, for example, to index the blocks. As FIG. 52 shows, a givenwave can include intra blocks of different sizes.

The decoder creates and populates the structure (5200), for example,when building waves. For example, the decoder performs an additionalpass through a picture during wave building and records indices in anarray of indices such as the structure (5200). The GPU then uses thestructure (5200) during the wave-by-wave intra prediction.

4. Merging Luma Waves and Chroma Waves.

In some embodiments, the decoder (with GPU) merges luma waves and chromawaves to increase parallelism. When chroma prediction is independent ofluma prediction, merging luma waves and chroma waves helps the GPUreduce the total number of waves and process more intra blocks inparallel within a given wave.

FIG. 53 shows an example technique (5300) for merging luma waves andchroma waves. A decoder such as the one described above with referenceto FIG. 2 or other decoder performs the technique (5300).

The decoder organizes (5310) intra luma blocks as waves. For example,the decoder uses a wave building technique described above or usesanother wave building technique. The decoder also organizes (5320) intrachroma blocks as waves. The decoder can use the same or different wavebuilding techniques for chroma blocks, performing the organizing (5310,5320) separately in time or concurrently.

The decoder then merges (5330) the luma waves and chroma waves. Forexample, the decoder combines luma intra blocks for wave 0 with chromaintra blocks for wave 0, and so on. The luma intra blocks and chromaintra blocks with a wave may be collocated, or they may be at differentlocations due to different dependencies for luma and chroma. Lumaprediction modes can be different than chroma prediction modes, forexample, resulting in different dependencies.

5. Example Shaders with Refactored Intra Prediction Operations.

In some embodiments, the decoder (with GPU) uses refactored operationsfor intra prediction. This helps reduce wasted computation in intraprediction.

Formulas for different intra prediction modes have many computations incommon. For example, in the H.264 standard, there are nine intraprediction modes for 4×4 intra blocks, and some of the prediction modesinclude several branches, but the different branches and modes have manycomputations in common.

FIG. 54 shows sample positions (5400) around a 4×4 intra block (5410)considered in the intra prediction modes according to the H.264standard. Sample positions A, B, C and D are in the block above thecurrent block (5410), and sample positions E, F, G and H are in theblock above and to the right of the current block (5410). Sampleposition X is in the block above and left of the current block (5410),and sample positions I, J, K and L are in the block to the left of thecurrent block (5410). Different branches of the various 4×4 intraprediction modes address different cases of sample positions (5400)being available/unavailable for intra prediction, or provide slightlydifferent formulas for different positions with the current block(5410).

Several of the prediction modes compute (A+B+1)/2 as part of intraprediction. Several other prediction modes compute (A+2B+C+2)/4.Collectively, the intra prediction modes for intra 4×4 blocks (excludingthe DC prediction mode) can be refactored using the following completeset of computations: (A, B, C); (B, C, D); (C, D, E); (D, E, F); (E, F,G); (F, G, H); (G, H, H); (I, J, K); (J, K, L); (J, I, X); (I, X, A);(X, A, B); (K, L, L); (A, B); (B, C); (C, D); (D, E); (E, F); (F, G);(G, H); (I, J); (J, K); (K, L); (I, X); and (X, A), where the lettersrefer to the sample positions shown in FIG. 54, the refactoredoperations with three sample positions (x, y, z) refer to an operationof the form (x+2y+z+2)/4, and the refactored operations with two samplepositions (x, y) refer to an operation of the form (x+y+1)/2.

To reduce shader branches, a decoder can build a table that holds theresults of the refactored operations for some or all of the modes of anintra macroblock type, to simplify intra prediction by providing commonparts of possible prediction results for those modes. The decoder thenselects the appropriate results when performing the intra predictionactually specified for the current block. For example, the decoderbuilds a table for eight 4×4 intra prediction modes (not DC mode) for acurrent 4×4 intra block and uses the table in intra prediction for theblock, selecting appropriate values for a spatial prediction mode. Thedecoder handles DC mode separately.

The decoder can compute the values for the table using matrixmultiplications. For example, the decoder computes the results ofrefactored operations for 4×4 intra prediction modes with two 4×4 matrixmultiplications as follows.

${\begin{bmatrix}A & B & C & D \\I & J & K & L \\J & I & X & A \\I & X & A & B\end{bmatrix} \cdot \begin{bmatrix}1 & 0 & 1 & 0 \\2 & 1 & 1 & 1 \\1 & 2 & 0 & 1 \\0 & 1 & 0 & 0\end{bmatrix}}\mspace{14mu} {{{and}\mspace{14mu}\begin{bmatrix}C & D & E & F \\E & F & G & H \\G & H & H & 0 \\K & L & L & 0\end{bmatrix}} \cdot \begin{bmatrix}1 & 0 & 1 & 0 \\2 & 1 & 1 & 1 \\1 & 2 & 0 & 1 \\0 & 1 & 0 & 0\end{bmatrix}}$

Alternatively, the results of the refactored operations are computed ina different way. Commonality refactoring can be performed similarly forthe prediction modes for other intra block sizes.

During intra prediction, the shader routine performs table lookups usingthe table. With the table, the number of branches in the shader isreduced, which speeds up execution and helps avoid wasted computation.Although computing the results of the refactored operations imposesadditional overhead, efficient mechanisms (e.g., matrix multiplications)for computing the results of refactored operations can be used.

G. Loop Filtering Innovations Using Waves for GPU-Platform Decoding.

In some embodiments, a decoder uses loop filtering operations mapped toa GPU platform. For example, the decoder organizes blocks as waves andperforms loop filtering on a wave-by-wave basis. Features of the exampleH.264-GPU mapping include:

-   -   1. using a multi-pass scheme for loop filtering on the GPU:        calculate boundary strength, luma loop filtering, chroma loop        filtering;    -   2. using fast boundary strength calculations;    -   3. building static waves to overcome dependencies in luma loop        filtering; and    -   4. creating fully parallelizable chroma loop filtering with no        edge dependencies.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures.

1. Multi-Pass Loop Filtering with GPU.

In some embodiments, a decoder performs loop filtering in multipleindependent passes to increase parallelism. For example, the differentpasses are for computing edge strengths, performing deblocking, andreshuffling results of the deblocking.

FIG. 55 shows an example technique (5500) for multi-pass loop filteringwith a GPU. A decoder such as the one described above with reference toFIG. 2 or other decoder performs the technique (5500).

In a first pass, the decoder (with GPU) calculates (5510) boundarystrengths and other data for each macroblock in a picture (or eachmacroblock pair for an MBAFF picture).

In a second pass, the decoder (with GPU) performs (5520) loop filteringon luma blocks and performs (5530) loop filtering on chroma blocks. Forexample, the loop filtering (5520, 5530) includes deblocking blocks inparallel according to different shaders for luma and chroma. The secondpass can include a luma pass with wave-by-wave loop filtering of lumablocks and a chroma pass with single-wave loop filtering of chromablocks. Loop filtering for a single wave can in turn be split intomultiple passes, for example, a horizontal edge pass and vertical edgepass for luma loop filtering. Alternatively, the decoder uses adifferent timing for loop filtering on the luma blocks and chromablocks.

In a third pass, the decoder (with GPU) shuffles (5540) sample valuesresulting from the second pass, in a fully parallel reshuffling stage.The sample values generated by the second pass are put into final imagebuffers. With the potential for reshuffling in the third pass, thedecoder can exploit additional opportunities for efficient processing inthe deblocking of the second pass.

2. Loop Filtering Using Waves for Luma Blocks.

In some embodiments, the decoder (with GPU) uses waves to efficientlyperform loop filtering of luma blocks on a GPU architecture. Basically,the GPU uses different execution units to process different luma blockswithin a wave in parallel.

FIG. 56 shows a technique (5600) for performing loop filtering usingwaves. A decoder such as the one described above with reference to FIG.2 or other decoder performs the technique (5600).

To start, the decoder organizes (5610) luma blocks as waves. In doingso, the decoder identifies luma blocks that can be loop filtered inparallel.

In some embodiments, the decoder organizes macroblocks (or macroblockpairs) as static waves along diagonal lines. Such static waves are laidout regardless of edge strengths, but the structure of the waves doesvary depending on the type of frame, MBAFF (macroblock pairs) or not.The static waves roughly correspond to diagonal lines of blocks,starting from the top left corner and rippling toward the bottom rightcorner. The number of waves relates to picture resolution anddimensions.

Alternatively, the decoder organizes luma blocks as dynamic waves,depending on boundary strengths. For example, boundary strength valuesare computed for a macroblock and used to reduce dependencies betweenthe macroblock and other macroblocks.

After organizing (5610) blocks as waves, the decoder performs loopfiltering on a wave-by-wave basis for the luma blocks. The decoderperforms (5620) loop filtering on luma blocks for a wave and determines(5630) whether to continue with another wave. If so, the decoderperforms (5620) loop filtering for the next wave.

In some embodiments, the decoder performs two passes for each loopfiltering wave. The decoder performs loop filtering on vertical edges inthe luma blocks in one pass, then it performs loop filtering onhorizontal edges in the luma blocks in another pass.

Depending on implementation, a 4×4 block in the picture can be exporteda variable number of times during different waves or passes within awave. For instance, in a progressive frame, the top-left 4×4 block of aninterior macroblock is exported for the vertical pass of its macroblock,and then for the horizontal pass. The bottom-right 4×4 block of the samemacroblock is exported for the vertical pass of its macroblock's wave,then for the horizontal pass of the same wave; it is also exported forthe vertical pass of the wave of the macroblock to its right, andfinally for the horizontal pass of the wave of the macroblock below it.In some implementations, the decoder uses a scratch buffer to avoidoverwriting data and make exports faster. When horizontal and verticalresults are deposited into separate memory locations, it is possible toget the right information from horizontal and vertical buffers of aprevious wave, or from the unfiltered pixels of the source image.

In some implementations, the decoder performs loop filtering by row orcolumn in parallel, not macroblock-by-macroblock. In one GPUimplementation, for each column or row of pixels in four 4×4 blocks in amacroblock, the decoder accepts five 4×4 blocks as input (namely, thefive blocks around four vertical or horizontal edges) and outputs six4×4 blocks. The decoder calculates and outputs one extra block above orto the left, and another one of padding for alignment purposes. Thisextra redundancy facilitates loop filtering according to the differentdependency rules that apply to macroblock interiors and at macroblockexternal edges, for example, so that the macroblocks in a diagonal(including the edge macroblocks) can be processed simultaneously.

3. Loop Filtering Chroma Blocks as a Single Wave.

In some embodiments, a decoder (with GPU) performs loop filtering forchroma blocks in a single wave. When chroma blocks in a picture do nothave dependencies for loop filtering (e.g., due to filters not reachingacross certain edges), the chroma blocks are processed in parallel bythe GPU. The chroma loop filtering can still include multiple passes forspecialized loop filtering processing of different positions.

For some macroblock formats and filter types, chroma blocks throughout apicture can be loop filtered in parallel by a GPU. For example, forchroma loop filtering of 4:2:0 macroblocks according to the H.264standard, chroma blocks have relatively few filtered edges, samples arespaced sufficiently far apart, and filters are sufficiently short, thatchroma blocks do not have associated dependencies in loop filtering. Assuch, chroma deblocking is performed without wave-by-wave processing.Instead, chroma blocks are loop filtered as part of a single wave.

The single wave loop filtering can include multiple passes for differentportions of the chroma blocks. The chroma blocks are processed inparallel, with different block portions being filtered in differentpasses.

For example, FIG. 57 shows an 8×8 chroma block (5700) of a progressivemacroblock. The 8×8 chroma block (5700) includes different portions thatare loop filtered in different loop filtering passes. Specifically, the8×8 chroma block (5700) has 9 regions: a 4×4 region (“M”) in the middle,two 2×4 regions (“S”) on the left and right sides of the middle, two 4×2regions (“T”) above and below the middle, and four 2×2 regions (“C”) inthe corners.

Different regions in a block can be processed independently of the otherregions in the block in loop filtering. Regions that touch the edge of amacroblock are processed together with the regions on the other side ofthe edge.

In some implementations, the chroma blocks of a picture are loopfiltered in four passes, without any waves. One pass corresponds to 4×4blocks centered around the top-left corners of the chroma blocks. Forthe 8×8 chroma block (5700) of FIG. 57 (collocated with the lumamacroblock and coextensive in the chroma plane), the block's top left2×2 corner is filtered in this pass, along with corners from up to threeother chroma blocks of macroblocks. The other 2×2 corners of the chromablock (5700) are similarly filtered in this pass with corner(s) fromother chroma block(s).

Another pass corresponds to 4×4 blocks centered on the top edges of themacroblocks (and collocated chroma blocks). The top 4×2 region of the8×8 block (5700) in FIG. 57 is filtered with the bottom 4×2 region ofthe block above it (if available), and the bottom 4×2 region of the 8×8block (5700) is filtered with the top 4×2 region of the block below it(if available).

Another pass correspond to 4×4 blocks centered on the left edges of themacroblocks (and collocated chroma blocks). The left side 2×4 region ofthe 8×8 block (5700) in FIG. 57 is filtered with the right side 2×4region of the block to the left (if available), and the right side 2×4region of the 8×8 block (5700) is filtered with the left side 2×4 regionof the block to the right (if available).

Another pass corresponds to 4×4 blocks centered on the macroblocks.

In some implementations, the loop filtering operations for chroma blocksuse a set of intermediate buffers and include some redundantcalculations. Overall, however, performing multi-pass loop filteringwithin a single wave has increased parallelism compared to wave-by-waveapproaches for chroma loop filtering.

FIG. 58 shows a set of 8×8 chroma blocks (5800) for a macroblock pair ina MBAFF picture. For MBAFF pictures, the multi-pass pattern for loopfiltering is more complicated. FIG. 58 shows example partitions formultiple passes. Other improvements in chroma loop filtering for MBAFFpictures include adaptive field/frame shaders and reducing the number ofredundant computations by adding another pass before reshuffling.

Alternatively, chroma blocks are filtered with other and/or additionalpasses in a single wave. Or, chroma blocks are loop filtered on awave-by-wave basis.

H. Memory Usage Innovations for GPU-Platform Decoding.

In some embodiments, a decoder uses memory usage innovations adapted fora GPU platform. For example, the decoder uses memory tiling and 3Dtexture arrays for fast data access. Features of the example GPU mappinginclude:

-   -   1. using texture arrays for reference pictures or other data;    -   2. using memory tiling for 4×4 block operations or other        operations;    -   3. using field/frame access mechanisms to efficiently store        frames and their complementary fields; and    -   4. using reference picture tiling.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures. For other operations or another type of GPU, the decoder usesdifferent memory usage innovations.

Memory write patterns can dramatically affect performance for the GPU.In some implementations, to improve performance, a picture is kept in a4×4 tiled format during decoding. This helps make both intra decodingand inter decoding (e.g., motion compensation) faster than if the normalscan line representation is used. Also, for deblocking, the decoderreads directly from the tiled image representation, which avoidsreshuffling.

Memory read patterns can also dramatically affect GPU performance. Insome implementations, the decoder extends the 4×4 tiled format toreference pictures in the decoded picture buffer (e.g., implemented as a3D texture). This facilitates fast fetching of data by motioncompensation shaders.

Other aspects of these memory usage innovations (e.g., representingreference pictures with textures, field/frame access, having multiplememory partitions or slot assignments in flight) are presented above(e.g., in section X.D or in conjunction with specific decodingoperations).

I. Film Grain Noise Generation for GPU-Platform Decoding.

In some embodiments, a decoder uses film grain noise generation mappedto a GPU platform. For example, the decoder (with GPU) generates filmgrain noise and performs deblocking (since the H.264 noise generation isblock-based). Features of the example H.264-GPU mapping include:

1. using pre-computed seed data; and

2. using pattern deblocking without dependencies.

Alternatively, the H.264-GPU mapping includes other and/or additionalfeatures.

According to the H.264 standard, certain types of supplementalenhancement information (“SEI”) messages support modeling of film grainas film grain parameters to be sent along with coded video. Aspost-processing, the decoded video can be enhanced with film grain noisesynthesized according to parameters. In some implementations, thedecoder (with GPU) improves performance of film grain synthesis by usingpre-computed seed data and/or performing pattern deblocking withoutdependencies.

J. Adaptive Loop Filtering with Quality Feedback for GPU-PlatformDecoding.

At times, a decoder may encounter content that is harder to decode(e.g., because it has a higher complexity or is encoded at a higherquality) or the decoder may experience an unexpected resource shortage(e.g., lack of available processor cycles or memory because of otherprocesses running). In such situations, the decoder may need to degradethe quality of the decoded video to simplify decoding. The decoder cando this by dropping pictures, for example, but picture dropping mayprovide more of an adjustment than is needed.

In some embodiments, a decoder uses adaptive loop filtering with qualityfeedback to gradually degrade video quality and simplify decoding. Thequality feedback generally relates to performance of the decoder as itdecodes video. For example, the decoder switches between differentdeblocking algorithms for loop filtering. In some implementations (e.g.,H.264 decoders), loop filtering is part of “conformant” decoding tocorrectly decode video, and changing loop filtering can result in driftaway from the correctly decoded video. Nevertheless, in some decodingscenarios, such quality degradation can be less objectionable to viewersthan picture dropping to simplify decoding. Performance-adaptive loopfiltering can be used in conjunction with picture dropping such thatplayback glitches due to picture dropping are reduced by selectivelyswitching loop filtering quality levels to relieve the decoder earlierin stress situations, and overall quality is improved.

FIG. 59 shows a technique (5900) for performance-adaptive loop filteringduring decoding. A decoder such as the one described above withreference to FIG. 2 or other decoder performs the technique (5900).

The decoder selects (5910) a loop filtering quality level from amongmultiple available loop filtering quality levels. Example quality levelsin some implementations (including no loop filtering, full loopfiltering, and multiple fast loop filtering options in between) aredescribed below. Alternatively, the decoder selects between other and/oradditional available loop filtering quality levels.

Initially, the selected loop filtering quality level has a value set forthe decoder or decoding session, for example, the highest loop filteringquality level. During decoding, the decoder can adjust the selected loopfiltering quality level from time-to-time, as described below.

The decoder decodes (5920) video, performing loop filtering at theselected loop filtering quality level. For example, the decoder decodesone or more pictures of the video at the selected loop filtering qualitylevel.

The decoder determines (5930) if it is done (e.g., at the end of thesequence) and, if not, measures (5940) performance. In someimplementations, the decoder measures a count of previously decodedpictures that are queued and ready for display, and the decoder alsomeasures how many decoded pictures in a given window, or range, ofpictures, have been decoded at a given quality level. Alternatively, thedecoder measures performance in other terms such as delay betweenpresentation times of pictures versus actual delay or another measure oflatency, or current processing capacity.

In some implementations, the decoder measures short-term performance andlong-term performance as part of performance-adaptive loop filtering.The decoder measures performance on picture-by-picture basis, forexample, by tracking a count of pictures ready for display. The decoderconcurrently measures longer term performance for n pictures in a windowof pictures. Alternatively, the decoder measures performance in someother interval.

Using the measured performance, the decoder determines (5950) whether tochange the loop filtering quality level. The decoder can use themeasured performance directly or indirectly in the determination (5950).For example, the decoder uses a performance metric directly inconditional logic or a table lookup operation to determine (5950)whether to change the quality level and, potentially, selects (5910) anew loop filtering quality level. Or, the decoder uses a performancemetric to adjust other parameter(s) or decision(s) in turn used indetermining (5950) whether to change the quality level. If the loopfiltering quality level is unchanged, the decoder continues decoding(5920) video with loop filtering at the same quality level. Otherwise,the decoder selects (5910) a new loop filtering quality level anddecodes (5920) video with loop filtering at the new quality level.

Loop filtering can be complex, especially when a decoder makescontent-adaptive and dynamic decisions depending on macroblock and blocktypes in a picture, sample value differentials across edges, etc. Inperformance-adaptive loop filtering, different available loop filteringquality levels basically trade off decoding complexity versus quality ofreconstruction of the decoded video. Faster loop filtering qualitylevels typically have lower decoding complexity but lower quality (e.g.,more discrepancies and drift due to skipped decisions in loopfiltering). The discrepancies can show up, for example, as increasedblurriness for lower complexity and quality loop filtering levels.Slower loop filtering quality levels typically have higher decodingcomplexity and higher quality. In some implementations, the decoderselects between the quality levels shown in the following table.

Loop Filtering Quality Level Description A. No loop filtering. Thedecoder performs no loop filtering. B. Fast loop filtering of Thedecoder performs non-conformant deblocking of the luma luma; no loopfiltering plane for a picture, filtering vertical edges of luma blockswithout of chroma. accounting for inter-MB dependencies, then filteringhorizontal edges of luma blocks without accounting for inter-MBdependencies. The decoder performs no loop filtering of the chromaplanes for the picture. C. Fast loop filtering of The decoder performsnon-conformant deblocking of the luma luma; conformant loop plane for apicture as in level B. The decoder performs full, filtering of chroma.conformant loop filtering of the chroma planes for the picture. D.Conformant loop The decoder performs conformant deblocking of the lumaplane for filtering of luma; no a picture. The decoder performs no loopfiltering of the chroma loop filtering of chroma. planes for thepicture. E. Conformant loop The decoder performs conformant deblockingof the luma plane filtering, and chroma planes for a picture.

Alternatively, the decoder uses other and/or additional loop filteringquality levels in performance-adaptive loop filtering for differenttradeoffs in decoding complexity, quality and robustness to levels ofperformance changes in decoding.

In some implementations, the decoder measures short-term performance asa count of how many pictures are buffered for digital to analogconversion (“DAC”). In particular, in one implementation, the decoderdetermines how far ahead pictures are buffered for DAC, measuring thedifference between (1) the most recent vertical blanking interval(“VBI”) or presentation time (generally, the time at which the DAC willrefresh the screen with video data from memory) and (2) the VBI orpresentation time for the picture as far ahead as any picture iscurrently scheduled for display. This count of pictures can beconsidered a queue length. Alternatively, the decoder uses anothermetric for short-term performance.

In some implementations, the decoder measures long-term performance asproportions of how many pictures in a window, or range, are decodedusing different quality levels. Alternatively, the decoder uses anothermetric for short-term performance.

In some implementations, the decoder uses a multi-stage framework toorganize the timing and types of level switching that happenperformance-adaptive loop filtering. In an example five-stage framework,each of five stages has associated with it one or more of quality levelsA to E, shown above. Each stage has different a “stage-best” qualitylevel within the stage. For stage 1, the stage-best quality level is A,for stage 2 the stage-best quality level is B, and so on. Within astage, the decoder selects between (1) level A, (2) the lesser of levelB and the stage-best quality level for the stage, and (3) the stage-bestquality level for the stage. The following table shows stages 1 to 5 inthe example five-stage framework.

Stage Stage-Best Level Available Quality Levels 1 A A, min(B, A), A =(A) 2 B A, min(B, B), B = (A, B) 3 C A, min(B, C), C = (A, B, C) 4 D A,min(B, D), D = (A, B, D) 5 E A, min(B, E), E = (A, B, E)

Within a stage, the decoder selects between the available loop filteringquality levels of the stage using (directly or indirectly) measuredperformance. For example, the decoder uses a current queue length (countof pictures ready for display) for short-term adjustments and uses aproportion of pictures decoded at stage-best quality levels forlong-term adjustments. Depending on these measures, the decoder canswitch from a current stage to a lower stage to decrease decodingcomplexity/quality, or the decoder can switch from the current stage toa higher stage to increase decoding complexity/quality. The decoder canswitch between stages one at a time or more aggressively switch betweenstages, depending on implementation.

In one implementation, the decoder evaluates current queue length fromtime-to-time (e.g., on a picture-by-picture basis) and switches to a lowcomplexity/quality level when the queue length gets too short. Forexample, if the queue length is less than two, the decoder performs noloop filtering (A) and switches to the next lower stage. Otherwise, ifthe queue length is less than four (but more than one), the decoderselects the lesser of level B and the stage-best quality level but staysin the current stage. Otherwise (queue length is four or more), thedecoder selects the stage-best quality level and stays in the currentstage. The thresholds for queue length also vary depending onimplementation.

In the same implementations, the decoder evaluates also evaluatesproportions of pictures decoded at stage-best levels from time-to-time(e.g., on a picture-by-picture basis) and switches betweencomplexity/quality levels depending on the proportions. For example, ifless than p % of the pictures in a current window of n pictures wereloop filtered at the stage-best level for the current stage, the decoderswitches to the next lower stage. Or, if more than q % of the picture inthe current window were loop filtered at the stage-best level for thecurrent stage, the decoder switches to the next higher stage. The valuesp, q and n depend on implementation and are, for example, p=80, q=90 andn=20. The decoder generally attempts to stay in the best quality stage(5 in the five-stage framework) as much as possible while still adaptingto decoding performance for the content.

The decoder can reset statistics (e.g., number of pictures deblocked atstage-best quality level or min(B, stage-best quality level) when awindow of pictures has been processed. Or, the decoder can use a slidingwindow. The decoder typically resets such statistics when it changesstages in a multi-stage framework.

Alternatively, the decoder uses a framework for performance-adaptiveloop filtering with different timing and/or types of loop filteringquality level switching.

XIII. Features.

Different embodiments may include one or more of the inventive featuresshown in the following table of features.

# Feature A. Multithreading Innovations. A1 A method comprising:selecting a threading mode from among plural available threading modes,the plural available threading modes including a single CPU thread mode,a multiple CPU thread mode, and a one or more CPU thread plus GPU threadmode; and decoding video in the selected threading mode. A2 A methodcomprising: identifying decoding dependencies for plural macroblocks ofa picture; organizing the plural macroblocks as one or more segments formultithreaded decoding, each of the one or more segments including apart of a slice, a slice, plural slices, or parts of plural slices; anddecoding the picture, including scheduling the one or more segments formultithreaded decoding on a segment-by-segment basis. RecoveryMechanisms A3 A method comprising: finding a picture in an encoded videobit stream; determining if the picture is an I picture; if the pictureis an I picture, scheduling one or more decoding tasks for the picturefor multithreaded decoding; and if the picture is not an I picture,cleaning up the picture and repeating the method for a next picture inthe encoded video bit stream. A4 The method of A3 wherein the findingincludes initializing structures for parameters and data for thepicture, and wherein the cleaning up includes releasing memory used bythe parameters and data for the picture. A5 The method of A3 furthercomprising detecting corruption in the encoded video bit stream, whereina decoder performs the finding as part of recovery from the corruptionin the encoded video bit stream. A6 The method of A3 further comprisingreceiving an indicator of an arbitrary location within the encoded videobitstream, wherein a decoder performs the finding as part of start up ofdecoding from the arbitrary location within the encoded video bitstream.A7 A method comprising: catching an error during decoding of a picturefrom an encoded video bit stream; determining if the error is fatal; ifthe error is fatal, cleaning up the picture; if the error is not fatal,determining whether the picture successfully enters a decoded picturebuffer; if the picture successfully enters the decoded picture buffer,marking the picture as skipped; and otherwise, cleaning up the picture.A8 The method of A7 wherein the error is a non-fatal slice header errorfor a slice in the picture, wherein the picture fails to successfullyenter the decoded picture buffer, and wherein decoding continues with anext picture. A9 The method of A7 wherein the cleaning up the pictureinclude removing commands in a picture command queue and releasingmemory used for structures for the picture. A10 The method of A7 whereina decoder performs the method, wherein the error is a fatal error, themethod further comprising closing the decoder. A11 The method of A7wherein, if the error is non-fatal, the method further comprisesrepeating the method for one or more other pictures from the encodedvideo bit stream until an error-free picture is found or a fatal erroris encountered. A12 A method comprising: catching an error duringdecoding of a picture from an encoded video bit stream; if the erroroccurred during a picture extent discovery stage, processing the errorby cleaning up the picture or skipping decoding of the picture; and ifthe error occurred during another stage, processing the error usingerror handling. A13 The method of A12 wherein the error indicates partof the encoded video bit stream for a slice in the picture is corrupted,and wherein the error handling comprises skipping decoding of the slicebut decoding one or more other slices in the picture. A14 The method ofA12 wherein the error indicates part of the encoded video bit stream fora slice in the picture is corrupted, and wherein the error handlingcomprises concealing the error for the slice and decoding one or moreother slices in the picture. B. Innovations in Neighbor Determination.B1 A method comprising: getting one or more tables indicating neighboravailability relationships between macroblocks, blocks and/orsub-blocks; and using the one or more tables to determine neighboravailability during decoding operations. B2 The method of B1 wherein theone or more tables includes a first availability table indicatingdifferent macroblock neighbor or macroblock pair neighbor patterns and asecond availability table indicating different sub- macroblock neighborpatterns. B3 The method of B2 wherein the first availability table ispre-determined. B4 The method of B2 wherein the second availabilitytable is created for a decoding session. B5 The method of B1 wherein thedecoding operations are for a progressive picture or field picture, andwherein the neighbor availability includes macroblock neighboravailability. B6 The method of B1 wherein the one or more tables includea first availability table and a second availability table, and whereinthe using the one or more tables includes: setting up a state machinefor plural macroblocks in a slice; determining macroblock neighboravailability using the state machine and the first availability table;and determining sub-macroblock neighbor availability using themacroblock neighbor availability and the second availability table. B7The method of B6 wherein, for a given state, the state machine storesinformation indicating number of consecutive macroblocks in the stateand an index to the first availability table indicating availabilityinformation for the state. B8 The method of B6 wherein the firstavailability table associates different states with different macroblockneighbor availability patterns. B9 The method of B6 wherein the secondavailability table associates different macroblock neighbor availabilitypatterns with different block/sub- block neighbor availability patterns.B10 The method of B1 wherein the decoding operations are for amacroblock adaptive field frame picture, and wherein the neighboravailability includes macroblock pair neighbor availability. B11 Themethod of B1 wherein the one or more tables include a first availabilitytable and a second availability table, and wherein the using the one ormore tables includes: setting up a state machine for plural macroblockpairs in a slice; setting up a neighbor context vector for eachmacroblock of the plural macroblock pairs in the slice; determiningmacroblock pair neighbor availability using the state machine and thefirst availability table; determining sub-macroblock neighboravailability using the macroblock pair neighbor availability and thesecond availability table. B12 The method of B11 wherein the neighborcontext vector indicates field or frame mode for a current macroblockpair, field or frame mode for each of plural neighbor macroblock pairs,and whether the current macroblock is a top or bottom macroblock in itsmacroblock pair. B13 The method of B11 wherein, for a given state, thestate machine stores information indicating number of consecutivemacroblock pairs in the state and an index to the first availabilitytable indicating availability information for the state. B14 The methodof B11 wherein the first availability table associates different stateswith different macroblock pair neighbor availability patterns. B15 Themethod of B11 wherein the second availability table associates differentmacroblock pair neighbor availability patterns and current macroblockpatterns with different block/sub-block neighbor availability patterns.B16 The method of B1 wherein the using the one or more tables includesstoring location information for neighboring macroblocks. B17 The methodof B14 wherein the location information is stored as offsets from acurrent macroblock. B18 The method of B1 wherein the decoding operationsinclude one or more of CABAC decoding, spatial intra prediction, modecomputation for intra prediction, and CAVLC decoding. B19 The method ofB1 wherein the using the one or more tables involves a hierarchicaldetermination at macroblock level then sub-macroblock level. B20 Amethod comprising: determining macroblock or macroblock pair neighboravailability during decoding operations; and determining sub-macroblockneighbor availability during the decoding operations using informationfrom the determined macroblock or macroblock pair neighbor availability.C. CABAC Decoding Innovations. C1 A method comprising: entropy decodingencoded video information from an encoded video bit stream, the encodedvideo information having been encoded using context- adaptive binaryarithmetic coding, wherein the entropy decoding comprises: loading bitsof the encoded video information from the encoded video bit stream on amachine word-by-machine word basis, as necessary, for context-adaptivebinary arithmetic decoding; and using results of the entropy decoding inreconstruction of the video information. C2 The method of C1 wherein themachine word has 32 bits or 64 bits. C3 A method comprising: entropydecoding encoded video information from an encoded video bit stream, theencoded video information having been encoded using context- adaptivebinary arithmetic coding, wherein the entropy decoding comprises:storing an encoded video information value being decoded and pluralavailable stream bits together in a first variable; storing bit countinformation for the first variable in a second variable; and using thefirst and second variables in context-adaptive binary arithmeticdecoding; and using results of the entropy decoding in reconstruction ofthe video information. C4 The method of C3 further comprising loadingthe plural available stream bits directly into the first variable fromthe encoded video bit stream. C5 The method of C3 further comprising,during the context-adaptive binary arithmetic decoding: left shiftingthe first variable by one or more bits, thereby updating the encodedinformation value being decoded and incorporating one or more of theplural available stream bits stored in the first variable; and updatingthe bit count information in the second variable. C6 The method of C5further comprising: determining whether or not to replace stream bits inthe first variable; and if stream bits are to be replaced, adding atleast some new stream bits from the encoded video bit stream to thefirst variable. C7 The method of C6 wherein stream bits are added on ahalf-word-by-half word basis. C8 A method comprising: entropy decodingencoded video information from an encoded video bit stream, the encodedvideo information having been encoded using context- adaptive binaryarithmetic coding, wherein the entropy decoding comprises, duringrenormalization in context-adaptive binary arithmetic decoding:determining a multiplication amount; and multiplying a range by themultiplication amount; and using results of the entropy decoding inreconstruction of the video information. C9 The method of C8 wherein themultiplying comprises left shifting by a left shift amount correspondingto the multiplication amount. C10 The method of C8 further comprising:left shifting an encoded information value being decoded by a left shiftamount corresponding to the multiplication amount. C11 The method of C8wherein the multiplication amount is a dynamic shift amount, and whereinthe multiplying comprises performing a dynamic shift operation. C12 Themethod of C8 wherein a table maps different range values to differentmultiplication amounts, and wherein the determining comprises looking upthe range in the table to find a multiplication amount. C13 The methodof C8 wherein unrolled loop logic maps at least some different rangevalues to different multiplication amounts, and wherein the determiningcomprises traversing the unrolled loop logic. C14 The method of C13wherein the determined multiplication amount is one of the differentmultiplication amounts in the unrolled loop logic, and wherein themultiplying comprises performing a fixed shift operation. C15 The methodof C13 wherein a table maps remaining range values to othermultiplication amounts, and wherein the determining comprises traversingthe unrolled loop logic then looking up the range in the table to findthe multiplication amount. C16 A method comprising: entropy decodingencoded video information from an encoded video bit stream, the encodedvideo information having been encoded using context- adaptive binaryarithmetic coding, wherein the entropy decoding comprises: splittingcontext-adaptive binary arithmetic decoding for frequency coefficientsinto plural context-adaptive binary arithmetic decoding units, each ofthe plural context-adaptive binary arithmetic decoding units beingadapted for a different frequency interval for the fiequencycoefficients; and using results of the entropy decoding inreconstruction of the video information. C17 The method of C16 whereinthe plural context-adaptive binary arithmetic decoding units include afirst decoding unit adapted for a lower frequency interval and a seconddecoding unit adapted for a higher frequency interval. C18 The method ofC16 wherein the entropy decoding further comprises, calling a coredecoding function from each of the plural context-adaptive binaryarithmetic decoding units. C19 The method of C16 wherein each of theplural context adaptive binary arithmetic decoding units includes logicadapted for probabilistic expectations of the frequency interval of thecontext adaptive binary arithmetic decoding unit. C20 The method of C19wherein the entropy decoding further comprises, for each of the pluralcontext adaptive binary arithmetic decoding units: calling a coredecoding function from within the logic adapted for probabilisticexpectations of the frequency interval of the context adaptive binaryarithmetic decoding unit. C21 A method comprising: entropy decodingencoded video information from an encoded video bit stream, the encodedvideo information having been encoded using context- adaptive binaryarithmetic coding, wherein the entropy decoding comprises: using a statemachine that calls a core decoding function for context-adaptive binaryarithmetic decoding; and using results of the entropy decoding inreconstruction of the video information. C22 The method of C21 whereinthe state machine implements a cascade of conditional logic using aposition state and transition table. C23 The method of C22 wherein thetransition table indicates a next state based at least in part upon acurrent state and results of a call to the core decoding function. C24The method of C21 wherein the state machine implements logic for a firstdecoding function, and wherein the entropy decoding further comprises:using a second state machine that calls the core decoding function forcontext-adaptive binary arithmetic decoding, wherein the second statemachine implements logic for a second decoding function different thanthe first decoding function. D. Trick Play Mode Innovations. D1 A methodcomprising: decoding video in a first playback mode of a decoder;receiving a mode switch command; draining the decoder; and decodingvideo in a second playback mode of the decoder, the second playback modebeing different than the first playback mode. D2 The method of D1wherein the first playback mode is a normal playback mode and the secondplayback mode is a trick mode. D3 The method of D1 wherein the firstplayback mode is a trick mode and the second playback mode is a normalplayback mode. D4 The method of D1 wherein the first playback mode is afirst trick mode and the second playback mode is a second trick mode. D5The method of D1 wherein at least one of the first playback mode and thesecond playback mode is a trick mode, and wherein the trick mode is fastforward mode or fast backward mode. D6 The method of D6 wherein, for thetrick mode, the decoder decodes only I pictures. D7 The method of D6wherein, for the trick mode, the decoder decodes only I pictures, andwherein the decoder provides multiple display rate options in whichdifferent proportions of I pictures are skipped. D8 The method of D1wherein the draining the decoder includes stopping input to the decoderuntil the decoder consumes what it has previously accepted as input inthe first playback mode. D9 The method of D1 wherein the draining thedecoder includes releasing memory used for the decoding video in thefirst playback mode and/or waiting for working threads for the decodingto rest. D10 The method of D1 wherein, for the trick mode, the decoderbypasses DPB management logic used in multithreaded decoding. D11 Amethod comprising: switching from a normal video playback mode to atrick video playback mode; and decoding video in the trick playbackmode, wherein one or more delay reduction mechanisms reduce latency inswitching from the normal video playback mode to the trick videoplayback mode. D12 The method of D11 wherein the one or more delayreduction mechanisms include reducing size of an output buffer. D13 Themethod of D11 wherein the one or more delay reduction mechanisms includeoutputting decoded pictures directly to an output buffer, bypassingdecoded picture buffer logic. D14 The method of D11 wherein the one ormore delay reduction mechanisms include finding I pictures in an encodedvideo bit stream by seeking special-purpose access delimiters. E.Recovery Using Picture Dropping. E1 A method comprising: creating adependency tracking structure in which reference relationships betweenat least some of plural pictures of a video sequence are tracked; in apicture dropping mode, selecting one or more of the plural pictures todrop based at least in part on the dependency tracking structure;decoding plural non-dropped pictures among the plural pictures; andoutputting the plural non-dropped decoded pictures for display. E2 Themethod of E1 wherein the dependency tracking structure is a taskdependency graph that organizes decoding tasks for segments, and whereinthe reference relationships are represented in the task dependency graphas dependencies between some of the decoding tasks for segments. E3 Themethod of E1 wherein the dependency tracking structure includes nodesand edges, and wherein at least some of the edges indicate the referencerelationships. E4 The method of E1 further comprising marking the one ormore selected pictures to drop as skipped, wherein decoding is skippedfor the one or more skipped pictures. E5 The method of E4 wherein adecoded picture buffer tracks the plural non-dropped decoded picturesand tracks the one or more skipped pictures. E6 The method of E4 whereinthe marking includes updating the dependency tracking structure for theone or more skipped pictures. E7 The method of E4 wherein the markingincludes: marking a first picture of the one or more skipped pictures asskipped in the dependency tracking structure; and propagating skippedstatus to at least one other picture of the one or more skippedpictures, the at least one other picture being dependent on the firstpicture for reference. E8 The method of E1 wherein a picture extentdiscovery module of a decoder performs the selecting. E9 The method ofE1 further comprising: receiving a control signal; and selecting thepicture dropping mode from among plural available picture dropping modesbased at least in part upon the received control signal. E10 The methodof E9 wherein the plural available picture dropping modes include nodropping, dropping non-referenced pictures, dropping B pictures andpictures referencing them, dropping P pictures and pictures referencingthem, and dropping all but I pictures. E11 A method comprising: findinga picture in an encoded video bit stream; determining whether or not todrop the picture; if the picture is not dropped, decoding the picture,wherein the decoded picture has an entry in a decoded picture buffer;and if the picture is dropped, skipping decoding of the picture butmaintaining an entry for the dropped picture in the decoded picturebuffer. E12 The method of E11 further comprising, if the picture isdropped: marking the picture as skipped; and recycling at least some ofresources allocated for the picture. E13 The method of E11 furthercomprising repeating the method for each of one or more other picturesin the encoded video bit stream. E14 The method of E11 wherein the entryfor the dropped picture in the decoded picture buffer is an initialized,un-decoded picture. E15 The method of E11 wherein the entry for thedropped picture in the decoded picture buffer indicates the droppedpicture was skipped. E16 A method comprising: selecting a picturedropping mode from among plural available picture dropping modes,wherein the plural available picture dropping modes include no dropping,dropping non-referenced pictures, dropping B pictures and picturesreferencing them, dropping P pictures and pictures referencing them, anddropping all but I pictures; in the selected picture dropping mode,decoding video of a video sequence that includes plural pictures;outputting plural non-dropped decoded pictures among the plural picturesfor display. E17 The method of E16 further comprising receiving acontrol signal, wherein the selecting is based at least in part upon thereceived control signal. F. Innovations in Computing ContextualInformation for Direct Mode Macroblocks. F1 A method comprising: for adirect mode macroblock, selecting among plural available collocatedmacroblock information routines to call depending on two or more of: (a)spatial/temporal mode decision used for the direct mode macroblock, (b)picture format of a second picture that includes the direct modemacroblock, and (c) picture format of the first picture; calling theselected collocated macroblock information routine to get collocatedmacroblock information for the direct mode macroblock; and using thecollocated macroblock information in reconstruction of the direct modemacroblock. F2 The method of F15 wherein the selecting is further basedupon one or more of: (d) macroblock pair format for a macroblock pairincluding the direct mode macroblock, and (e) macroblock position of thedirect mode macroblock in the MB pair. G. Reducing Memory ConsumptionDuring Multithreaded Decoding. G1 A method comprising: entropy decodingplural encoded transform coefficients; and packing at least some of thedecoded transform coefficients in one or more data structures, whereinthe packing includes representing an individual decoded transformcoefficient as a single multi-bit value including a block position and acoefficient level value packed together. G2 The method of G1 wherein theone or more data structures include a buffer fragment having pluralmulti-bit values for the at least some of the decoded transformcoefficients, the plural multi-bit values including the single multi-bitvalue. G3 The method of G1 wherein the one or more data structuresinclude an array of plural block count values for plural blocks of amacroblock, each of the plural block count values indicating a count ofnon-zero coefficients in a corresponding block of the plural blocks ofthe macroblock. G4 The method of G1 wherein the single multi-bit valuefurther includes an extension flag that indicates the presence orabsence of a second multi-bit value for storing an extension value forthe coefficient level value. G5 The method of G1 wherein the packingfurther includes skipping explicit representation of zero-value decodedtransform coefficients in the one or more data structures. G6 The methodof G1 further comprising, during later decoding, unpacking the packedtransform coefficients for inverse scanning and inverse quantizing. G7 Amethod comprising: entropy decoding plural encoded transformcoefficients; and packing at least some of the decoded transformcoefficients in one or more data structures, wherein the one or moredata structures include an array of plural block count values for pluralblocks of a macroblock, each of the plural block count values indicatinga count of non-zero coefficients in a corresponding block of the pluralblocks of the macroblock. G8 The method of G7 wherein the packingfurther includes skipping explicit representation of zero-value decodedtransform coefficients in the one or more data structures. G9 A methodcomprising: entropy decoding plural encoded transform coefficients; andbuffering at least some of the decoded transform coefficients in pluralthread-specific buffers. G10 The method of G9 wherein each of the pluralthread-specific buffers includes one or more buffer fragments anddynamically adds buffer fragments as needed. G11 The method of G10wherein each of the one or more buffer fragments is an array ofmulti-bit values, each of the multi-bit values representing one non-zero decoded transform coefficient. G12 The method of G10 wherein abuffer fragment pool includes free buffer fragments available foraddition to the plural thread-specific buffers. G13 A method comprising:decoding one or more pictures for a video frame including a top fieldand a bottom field, wherein the top field includes plural lines and thebottom field includes plural lines; and buffering the top and bottomfields together in a single frame memory buffer, the plural lines of thetop field alternating with the plural lines of the bottom field in thesingle frame memory buffer, wherein a top field structure facilitatesaccess to the buffered top field in the single frame memory buffer, andwherein a bottom field structure facilitates access to the bufferedbottom field in the single frame memory buffer. G14 The method of G13wherein the top field structure includes plural pointers to the plurallines of the buffered top field in the single frame memory buffer. G15The method of G13 wherein the bottom field structure includes pluralpointers to the plural lines of the buffered bottom field in the singleframe memory buffer. G16 The method of G13 wherein a frame structurefacilitates access to the video frame in the single frame memory buffer,and wherein the frame structure includes plural pointers to the plurallines of the single frame memory buffer. G17 The method of G13 whereinthe decoding includes decoding an encoded version of the video frame.G18 The method of G13 wherein the decoding includes decoding encodedversions of the top field and the bottom field. G19 A method comprising:allocating memory from plural memory pools, each of the plural memorypools storing available memory chunks adapted for a different decodingtask or adapted for a different one or more data structures used indecoding; and decoding video using the allocated memory. G20 The methodof G19 wherein, for a given memory pool of the plural available memorypools, each of the available memory chunks is sized for the differentdecoding task or one or more data structures for the given memory pool.H. Inverse Transform Innovations for GPU-platform Decoding. H1 A methodcomprising: receiving transform coefficients for video; classifying thetransform coefficients into plural types; and with a graphics processingunit, performing inverse transforms on the transform coefficients inplural passes corresponding to the plural types, respectively, whereineach of the plural types is associated with a quantum of work for thetype. H2 The method of H1 wherein the plural types are 4 × 4 luma, 4 × 4chroma and 8 × 8 luma. H3 The method of H2 wherein the quantum of workfor 4 × 4 luma is four 4 × 4 blocks of the transform coefficients. H4The method of H2 wherein the quantum of work for 4 × 4 chroma is two 4 ×4 blocks of the transform coefficients. H5 The method of H2 wherein thequantum of work for 8 × 8 luma is one 8 × 8 block of the transformcoefficients. H6 The method of H1 wherein the performing the inversetransforms uses native matrix multiplication operations and nativematrix addition operations. H7 A method comprising: receiving transformcoefficients for video; and with a graphics processing unit, performinginverse transforms on the transform coefficients using native matrixmultiplication operations and native matrix addition operations. I.Inverse Quantization Innovations for GPU-platform Decoding. I1 A methodcomprising: receiving transform coefficients for video; classifyinginverse quantization operations for the transform coefficients intoplural types; and with a graphics processing unit, performing inversequantization on the transform coefficients in plural passescorresponding to the plural types, respectively, wherein each of theplural types is associated with a quantum of work for the type. I2 Themethod of I1 wherein the plural types are DC luma, DC chroma, 4 × 4luma, 4 × 4 chroma and 8 × 8 luma. I3 The method of I2 wherein thequantum of work for DC luma is one 4 × 4 block of DC coefficients of thetransform coefficients. I4 The method of I2 wherein the quantum of workfor DC chroma is one 2 × 2 block of DC coefficients of the transformcoefficients. I5 The method of I2 wherein the quantum of work for 4 × 4luma is one 1 × 16 row of AC coefficients of the transform coefficients.I6 The method of I2 wherein the quantum of work for 4 × 4 chroma is two2 × 4 blocks of the transform coefficients. I7 The method of I2 whereinthe quantum of work for 8 × 8 luma is one 4 × 16 block of ACcoefficients of the transform coefficients. I8 The method of I1 whereinthe performing the inverse quantization uses a user-defined scaling listand/or normalization adjustment matrix. I9 The method of I8 wherein anarray of constant registers holds the user- defined scaling list and/ornormalization adjustment matrix. I10 The method of I1 wherein theperforming the inverse quantization uses a default scaling list and/ornormalization adjustment matrix. I11 A method comprising: receivingtransform coefficients for video; and with a graphics processing unit,performing inverse quantization on the transform coefficients using ascaling list, wherein an array of constant registers holds the scalinglist. I12 The method of I11 wherein the scaling list is a user-definedscaling list, the method further comprising receiving the user-definedscaling list signaled as part of a picture header in a coded video bitstream. I13 The method of I11 wherein the scaling list is a defaultscaling list. J. Fractional Interpolation Innovations for GPU-platformDecoding. J1 A method comprising: receiving plural motion vectors forvideo; classifying plural blocks into plural motion vector types; andwith a graphics processing unit, performing motion compensationoperations for the plural blocks with the plural motion vectors inplural passes corresponding to the plural motion vector types,respectively, wherein each of the plural motion vector types isassociated with a quantum of work for the motion vector type. J2 Themethod of J1 wherein the plural motion vector types are integer, centeroffset, and off-center offset. J3 The method of J2 wherein the quantumof work for each of the plural motion vector types is 8 × 8 block. J4The method of J2 wherein, for an integer pass of the plural passes, themotion compensation tasks include fetching sample values. J5 The methodof J2 wherein, for a center offset pass of the plural passes, a centeroffset shader routine implements the motion compensation operations. J6The method of J2 wherein, for an off-center offset pass of the pluralpasses, an off-center offset shader routine implements the motioncompensation operations. J7 The method of J1 wherein the plural motionvector types differ in terms of complexity of sample interpolation. J8The method of J1 wherein the motion compensation operations includefractional sample value interpolation. J9 The method of J1 whereinplural reference pictures for the motion compensation operations arerepresented as a 3 D texture. J10 The method of J1 wherein the motionvectors are applied for 4 × 4 blocks in the motion compensationoperations. J11 A method comprising: receiving plural motion vectors forvideo; and with a graphics processing unit, performing motioncompensation operations for plural blocks with the plural motionvectors, wherein the performing includes using an off-center offsetshader routine for off-center motion vectors among the plural motionvectors. J12 The method of J11 wherein the performing motioncompensation operations includes performing motion compensation on ablock-by-block basis for 4 × 4 blocks. J13 The method of J11 wherein theperforming motion compensation operations includes performing motioncompensation on a block-by-block basis and not storing intermediatevalues from block-to-block. J14 A method comprising: receiving pluralmotion vectors for video; and with a graphics processing unit,performing motion compensation operations for plural blocks with theplural motion vectors, wherein the performing includes using a centeroffset shader routine for center motion vectors among the plural motionvectors. J15 The method of J14 wherein the performing motioncompensation operations includes performing motion compensation on ablock-by-block basis for 4 × 4 blocks. J16 The method of J14 wherein theperforming motion compensation operations includes performing motioncompensation on a block-by-block basis and storing intermediate valuesfrom block-to-block. K. Intra Prediction Innovations Using Waves forGPU-platform Decoding. K1 A method comprising: organizing plural intrablocks as plural waves, each of the plural waves including one or moreof the plural intra blocks; and with a graphics processing unit,performing intra prediction on the plural intra blocks on a wave-by-wavebasis, including for at least one of the plural waves processing some ofthe one or more intra blocks within the wave in parallel. K2 The methodof K1 wherein the organizing includes: grouping a first set of one ormore of the plural intra blocks having no intra prediction dependencieson other intra blocks of the plural intra blocks; grouping a second setof one or more of the plural intra blocks having no intra predictiondependencies other than dependencies on the first set; and grouping athird set of one or more of the plural intra blocks having no intraprediction dependencies other than dependencies on the first and secondsets. K3 The method of K2 wherein the organizing is based upon staticassumptions of intra prediction dependencies for the plural intrablocks. K4 The method of K2 wherein the organizing is based upon actualintra prediction dependencies for the plural intra blocks. K5 The methodof K1 wherein the one or more intra blocks for at least one of theplural waves include a first intra block having a first block size and asecond intra block having a second block size different than the firstblock size. K6 The method of K1 wherein the plural intra blocks haveplural different block sizes, and wherein at least one of the pluralwaves includes a set of one or more intra blocks for each of the pluraldifferent block sizes. K7 The method of K1 wherein the organizingincludes: identifying plural actual intra prediction dependencies forthe plural intra blocks; and building the plural waves based at least inpart on the plural actual intra prediction dependencies. K8 The methodof K1 wherein the organizing includes: assigning an initial wave numberto each of the plural intra blocks; scanning a picture with the pluralintra blocks; and during the scanning, assigning increasing wave numbersto the plural intra blocks depending on intra picture dependencies forthe plural intra blocks. K9 The method of K1 wherein the plural intrablocks are in a P picture or B picture along with one or more non-intrablocks omitted from the plural waves. K10 The method of K1 wherein theplural intra blocks are in an I picture. K11 The method of K1 whereinthe plural intra blocks include plural luma blocks and plural chromablocks, wherein the plural waves are plural merged waves, and whereinthe organizing includes: identifying plural luma waves for the pluralluma blocks; identifying plural chroma waves for the plural chromablocks; and merging the plural luma waves and the plural chroma wavesinto the plural merged waves to increase parallelism within the pluralmerged waves. K12 The method of K11 wherein at least some collocatedluma blocks and chroma blocks are in different waves of the pluralmerged waves. K13 The method of K11 wherein the performing intraprediction includes for each of the plural merged waves processing atleast some of the plural luma blocks and at least some of the pluralchroma blocks in parallel. K14 The method of K1 wherein the intraprediction includes plural intra prediction modes, and wherein theperforming intra prediction includes applying results of refactoredoperations for the plural intra prediction modes, the refactoredoperations reducing branches in implementations of the plural intraprediction modes. K15 A method comprising: loading a table with resultsof refactored operations for plural intra prediction modes; and with agraphics processing unit, performing intra prediction on plural intrablocks in parallel, including using table-based lookups on the tablewith results of refactored operations for the plural prediction modes.L. Loop Filtering Innovations Using Waves for GPU-platform Decoding. L1A method comprising: organizing plural blocks as plural waves, each ofthe plural waves including one or more of the plural blocks; and with agraphics processing unit, performing loop filtering on the plural blockson a wave-by-wave basis, including for at least one of the plural wavesprocessing some of the one or more blocks within the wave in parallel.L2 The method of L1 wherein the plural blocks are luma blocks, themethod further comprising performing loop filtering on plural chromablocks as a single wave. L3 The method of L1 wherein the loop filteringincludes block-by-block processing along a row or column in amacroblock. L4 The method of L1 wherein the organizing includes:grouping a first set of one or more of the plural blocks having nodependencies on other blocks of the plural blocks; grouping a second setof one or more of the plural blocks having no dependencies other thandependencies on the first set; and grouping a third set of one or moreof the plural intra blocks having no dependencies other thandependencies on the first and second sets. L5 The method of L1 whereinthe organizing is based upon static assumptions of dependencies for theplural blocks. L6 The method of L1 wherein the organizing is independentof edge strengths of the plural blocks. L7 A method comprising: in afirst loop filtering pass for a picture, calculating boundary strengthvalues in parallel with a graphics processing unit; in a second loopfiltering pass for the picture: loop filtering plural luma blocks inparallel with the graphics processing unit; and loop filtering pluralchroma blocks in parallel with the graphics processing unit. L8 Themethod of L7 further comprising: in a third pass for the picture,reshuffling at least some results of the second loop filtering pass. L9The method of L7 wherein the second loop filtering pass includes a lumapass for the loop filtering the plural luma blocks and a chroma pass forthe loop filtering the plural chroma blocks. L10 The method of L9wherein the loop filtering the plural luma blocks includes: organizingthe plural luma blocks as plural waves; and performing the loopfiltering the plural luma blocks on a wave-by-wave basis. L11 The methodof L9 wherein the loop filtering the plural luma blocks includes ahorizontal edge pass and a vertical edge pass. L12 The method of L9wherein the loop filtering the plural chroma blocks includes performingthe loop filtering the plural chroma blocks as a single wave. L13 Amethod comprising: receiving plural chroma blocks; and loop filteringthe plural chroma blocks in parallel with a graphics processing unit asa single wave. L14 The method of L13 wherein the loop filtering theplural chroma blocks includes performing plural loop filtering passeswithin the single wave. L15 The method of L14 wherein the plural loopfiltering passes include a top-left corner pass, top edge pass, leftedge pass, and center pass. M. Memory Usage Innovations for GPU-platformDecoding. M1 A method comprising: decoding encoded video for a picturewith a graphics processing unit; during the decoding, buffering samplevalues for the picture in a tiled format; and after the decoding,buffering the decoded picture in a decoded picture buffer in the tiledformat for use as a reference picture. M2 The method of M1 wherein thetiled format is a tiled 4 × 4 format. M3 A method comprising:representing plural resource usage patterns for plural commands in agraphics processing unit command queue; and decoding plural pictures inserial coded order with a graphics processing unit, wherein the decodingincludes regulating memory based at least in part upon the pluralresource usage patterns. M4 The method of M3 wherein the resource usagepatterns are memory partition patterns for a memory array. M5 The methodof M3 wherein the resource usage patterns are reference picture slotassignment patterns for a memory array. M6 A method comprising:representing a reference picture as a texture in memory; and decodingone or more pictures of a video sequence with a graphics processingunit, including using texture operations to access the reference picturein memory during motion compensation. M7 The method of M6 wherein thereference picture is a first field reference picture, the method furthercomprising representing a second field reference picture in memory byalternating lines of the first and second field reference pictures inthe texture. M8 The method of M7 wherein the using the textureoperations includes: using texture operations on even lines of thetexture when accessing one of the first and second field referencepictures; using texture operations on odd lines of the texture whenaccessing the other of the first and second field reference pictures;and using texture operations on the even lines and the odd lines of thetexture when accessing the first and second field reference pictures asa reference frame. M9 The method of M6 wherein the texture is a plane ina 3 D texture, wherein the 3 D texture also represents one or more otherreference pictures. M10 A method comprising: representing pluralreference pictures as a 3 D texture in memory; and decoding one or morepictures of a video sequence with a graphics processing unit, includingusing texture operations to access one or more of the plural referencepicture in memory during motion compensation. M11 A method comprising:representing a top field reference picture and a bottom field referencepicture as alternating lines of a texture in memory; and decoding one ormore pictures of a video sequence with a graphics processing unit,including using texture operations to access one or more of the top andbottom field reference pictures in memory during motion compensation.M12 The method of M11 wherein the using the texture operations includes:using texture operations on even lines of the texture when accessing thetop field reference picture; using texture operations on odd lines ofthe texture when accessing the bottom field reference picture; and usingtexture operations on the even lines and the odd lines of the texturewhen accessing the top and bottom field reference pictures as areference frame. N. Performance-adaptive Loop Filtering N1 A methodcomprising: receiving video in an encoded video bit stream; and decodingthe video, wherein the decoding includes: measuring performance of thedecoding; selecting a loop filtering quality level from among pluralavailable loop filtering quality levels using the measured performance;and performing loop filtering at the selected loop filtering qualitylevel. N2 The method of N1 wherein the measured performance includes acount of pictures ready for display. N3 The method of N2 wherein thedecoding includes repeating the measuring of the count of pictures readyfor display and the selecting on a picture-by-picture basis for pluralpictures of the video. N4 The method of N1 wherein the measuredperformance includes proportion of pictures in a window that are decodedat a given loop filtering quality level among the plural available loopfiltering quality levels. N5 The method of N4 wherein the decodingincludes repeating the measuring the proportion and the selecting on apicture-by-picture basis. N6 The method of N1 wherein the selecting isbased at least in part upon one or more of a short-term performancemeasure and a long-term performance measure. N7 The method of N6 whereinthe short-term performance measure is a count of pictures ready fordisplay, and wherein the long-term performance measure is a proportionof pictures in a window that are decoded at a given loop filteringquality level. N8 The method of N1 wherein the plural available loopfiltering quality levels include a no loop filtering level, a full loopfiltering level, and one or more fast loop filtering levels, each of theone or more fast loop filtering levels being computationally simplerthan the full loop filtering level but lower quality. N9 The method ofN1 wherein the loop filtering is content adaptive and the selecting theloop filtering quality level is performance adaptive depending on one ormore of current computational capacity, complexity of the video beingdecoded and quality of the video being decoded. N10 The method of N1wherein the selecting comprises: determining whether to switch from acurrent quality stage to another quality stage and, if so, changing thecurrent quality stage to the other quality stage, wherein the currentquality stage is associated with one or more of the plural availableloop filtering quality levels, and wherein within the current qualitystage the selecting selects between the one or more available loopfiltering quality levels associated with the current quality stage.

In view of the many possible embodiments to which the principles of thedisclosed invention may be applied, it should be recognized that theillustrated embodiments are only preferred examples of the invention andshould not be taken as limiting the scope of the invention. Rather, thescope of the invention is defined by the following claims. We thereforeclaim as our invention all that comes within the scope and spirit ofthese claims.

1.-20. (canceled)
 21. A non-volatile memory device having stored thereinencoded data for a picture that includes plural portions, the encodeddata being organized to facilitate video processing, by a computersystem, according to video processing operations comprising: receivingthe encoded data for the picture that includes plural portions; anddecoding the encoded data to reconstruct the picture, includingperforming decoding operations for the plural portions of the picture,on a wave-by-wave basis, as plural waves, the plural portions of thepicture having variable size, each of the plural waves including one ormore of the plural portions of the picture, wherein, for at least one ofthe plural waves, at least some of the one or more portions within thewave are processed in parallel, wherein the plural waves ripple from atop-left corner of the picture toward a bottom-right corner of thepicture, wherein each of the plural waves depends on results of thedecoding operations for preceding waves among the plural waves, andwherein, for each of the plural waves, for each given portion of thewave the decoding operations have completed for (1) the portion, if any,left of the given portion, (2) the portion, if any, above-left of thegiven portion, (3) the portion, if any, above the given portion, and (4)the portion, if any, above-right of the given portion.
 22. Thenon-volatile memory device of claim 21, wherein each of the pluralportions is an arrangement of sample values for luma with associatedarrangements of sample values for chroma, and wherein the plural wavesroughly correspond to diagonal lines of portions of the picture.
 23. Thenon-volatile memory device of claim 21, wherein execution units of agraphics processing unit (“GPU”) perform the decoding operations for theplural portions of the picture on a wave-by-wave basis.
 24. Thenon-volatile memory device of claim 21, wherein the plural portions ofthe picture are intra-coded, and wherein the decoding operations includeintra prediction operations.
 25. The non-volatile memory device of claim21, wherein the decoding operations include loop filtering operations.26. The non-volatile memory device of claim 21, wherein the pictureincludes multiple slices, without dependencies between the multipleslices, and wherein the plural portions are part of one of the multipleslices of the picture.
 27. The non-volatile memory device of claim 21,wherein each of the plural portions, having variable size, can bepartitioned into multiple blocks, and wherein at least some of themultiple blocks for the plural portions have different block sizes. 28.The non-volatile memory device of claim 21, wherein the decodingoperations include context-adaptive binary arithmetic decodingoperations, the context-adaptive binary arithmetic decoding operationsincluding, for one of the plural portions not having dependencies onother portions of the plural portions, initialization of variables. 29.A computer system comprising one or more processing units, memory, andstorage, wherein the memory and/or the storage has stored thereincomputer-executable instructions for causing the computer system, whenprogrammed thereby, to perform video processing comprising: receivingencoded data for a picture that includes plural portions; and decodingthe encoded data to reconstruct the picture, wherein the decoding theencoded data includes performing decoding operations, includingcontext-adaptive binary arithmetic decoding operations, for the pluralportions of the picture, the context-adaptive binary arithmetic decodingoperations including, for one of the plural portions not havingdependencies on other portions of the plural portions, initialization ofvariables, and wherein the decoding the encoded data further includesperforming at least some of the decoding operations for the pluralportions of the picture, on a wave-by-wave basis, as plural waves, theplural portions of the picture having variable size, each of the pluralwaves including one or more of the plural portions of the picture,wherein, for at least one of the plural waves, at least some of the oneor more portions within the wave are processed in parallel, wherein theplural waves ripple from a top-left corner of the picture toward abottom-right corner of the picture, wherein each of the plural wavesdepends on results of the at least some of the decoding operations forpreceding waves among the plural waves, and wherein, for each of theplural waves, for each given portion of the wave the at least some ofthe decoding operations have completed for (1) the portion, if any, leftof the given portion, (2) the portion, if any, above-left of the givenportion, (3) the portion, if any, above the given portion, and (4) theportion, if any, above-right of the given portion.
 30. The computersystem of claim 29, wherein each of the plural portions is anarrangement of sample values for luma with associated arrangements ofsample values for chroma, and wherein the plural waves roughlycorrespond to diagonal lines of portions of the picture,
 31. Thecomputer system of claim 29, wherein execution units of a graphicsprocessing unit (“GPU”) perform the at least some of the decodingoperations for the plural portions of the picture on a wave-by-wavebasis.
 32. The computer system of claim 29, wherein: the plural portionsof the picture are intra-coded, and the at least some of the decodingoperations include intra prediction operations; and/or the at least someof the decoding operations include loop filtering operations.
 33. Thecomputer system of claim 29, wherein the picture includes multipleslices, without dependencies between the multiple slices, and whereinthe plural portions are part of one of the multiple slices of thepicture.
 34. The computer system of claim 29, wherein each of the pluralportions, having variable size, can be partitioned into multiple blocks,and wherein at least some of the multiple blocks for the plural portionshave different block sizes.
 35. A method comprising: receiving encodeddata for a picture that includes plural portions; and decoding theencoded data to reconstruct the picture, wherein the decoding theencoded data includes performing decoding operations, includingcontext-adaptive binary arithmetic decoding operations, for the pluralportions of the picture, the context-adaptive binary arithmetic decodingoperations including, for one of the plural portions not havingdependencies on other portions of the plural portions, initialization ofvariables, and wherein the decoding the encoded data further includesperforming at least some of the decoding operations for the pluralportions of the picture, on a wave-by-wave basis, as plural waves, theplural portions of the picture having variable size, each of the pluralwaves including one or more of the plural portions of the picture,wherein, for at least one of the plural waves, at least some of the oneor more portions within the wave are processed in parallel, wherein theplural waves ripple from a top-left corner of the picture toward abottom-right corner of the picture, wherein each of the plural wavesdepends on results of the at least some of the decoding operations forpreceding waves among the plural waves, and wherein, for each of theplural waves, for each given portion of the wave the at least some ofthe decoding operations have completed for (1) the portion, if any, leftof the given portion, (2) the portion, if any, above-left of the givenportion, (3) the portion, if any, above the given portion, and (4) theportion, if any, above-right of the given portion.
 36. The method ofclaim 35, wherein each of the plural portions is an arrangement ofsample values for luma with associated arrangements of sample values forchroma, and wherein the plural waves roughly correspond to diagonallines of portions of the picture,
 37. The method of claim 35, whereinexecution units of a graphics processing unit (“GPU”) perform the atleast some of the decoding operations for the plural portions of thepicture on a wave-by-wave basis.
 38. The method of claim 35, wherein:the plural portions of the picture are intra-coded, and the at leastsome of the decoding operations further include intra predictionoperations; and/or the at least some of the decoding operations furtherinclude loop filtering operations.
 39. The method of claim 35, whereinthe picture includes multiple slices, without dependencies between themultiple slices, and wherein the plural portions are part of one of themultiple slices of the picture.
 40. The method of claim 35, wherein eachof the plural portions, having variable size, can be partitioned intomultiple blocks, and wherein at least some of the multiple blocks forthe plural portions have different block sizes.